4

Folks,

I plan to use Python and various python packages like robot framework, appium, selenium etc for test automation. But as we all know, python and all the package versions keep revving.

If we pick a version of all of these to start with, and as these packages up rev, what is the recommended process for keeping the development environment up to date with the latest versions?

Appreciate some guidance on this.

Thanks.

utpal
  • 331
  • 5
  • 13
  • Make use of virtual environments, `requirements.txt` (with version pinning or not) and `pip list --outdated`. – Klaus D. Dec 14 '18 at 14:50
  • I would definitely recommend using virtualenv/venv for managing the Python packages for each project. For running tests specifically, I would probably use the `tox` tool, as it automates many of these steps already. However, for things like Selenium, which have broader OS-level dependencies, you might be better off working on running your tests inside a Docker container, so that you can isolate all the test dependencies from the rest of your system. – Daniel Pryden Dec 14 '18 at 15:24
  • @DanielPryden can I drive Browsers/GUI based apps from inside a docker container? The tests I want to run are running on windows, testing windows applications using. – utpal Dec 14 '18 at 15:43

2 Answers2

5

If you wrote the code with a given version of a library, updating that library in the future is more likely to break your code than make it run better unless you intend to make use of the new features. Most of the time, you are better off sticking with the version you used when you wrote the code unless you want to change the code to use a new toy.

In order to ensure that the proper versions of every library are installed when the program is loaded on a new machine, you need a requirements.txt document. Making one of these is easy. All you do is build your program inside a virtual environment (e.g. conda create -n newenv conda activate newenv) Only install libraries you need for your program and then, once all of your dependencies are installed, in your terminal, type pip freeze > requirements.txt. This will put all your dependencies and their version information in the text document. When you want to use the program on a new machine, simply incorporate pip install -r requirements.txt into the loading process for the program.

If you containerize it using something like docker, your requirements.txt dependencies can be installed automatically whenever the container is created. If you want to use a new library or library version, simply update it in your requirements.txt and boom, you are up to date.

0

In this case you would want to isolate your package (and the external packages/versions it depends on) using a virtual environment. A virtual environment can be thought of as a file that tracks the specific package versions you're importing. Thus you can have the latest package installed on your system, but your project will still only import the version in your virtual environment.

C3Theo
  • 53
  • 1
  • 9