From 144a5b20c5c4503fe16519aeeaffece4a114aa72 Mon Sep 17 00:00:00 2001 From: Nick Coghlan Date: Nov 01 2017 06:53:25 +0000 Subject: Check Fedora 26 compatibility F26 has requests 2.13 (Jan 2017), and response objects only gained native context management support in 2.18 (Jun 2017). This adds a new "tox -e system" test environment to check operation with system packages, and bumps the version to 0.0.2 --- diff --git a/README.md b/README.md index 02ab2a8..62e4fe0 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,10 @@ The tests can then be run in the launched subshell with: $ pytest tests +To test the package build process, tox is also supported: + + $ tox -e py36 + ### Reviewing project dependencies @@ -168,3 +172,21 @@ To see the Python level dependencies graph: (If you don't turn off global site-packages access first, you'll get the dependency graph of all the installed system Python components as well) + + +### Testing Fedora system package compatibility + +While the default development environment is managed with `pipenv` for a more +consistent cross-platform development experience, `fedmod` is intended to +support installation as a system package in Fedora 26 and later. + +A specific tox environment is provided to enable this testing: + + $ tox -e system + +The only component this installs into the environment is `fedmod` itself: all +other dependencies must be available as Python 3 system packages. + +Unlike the regular test environment, this environment also implicitly runs +`fedmod fetch-metadata` in order to ensure that the metadata fetching operation +also works correctly given only system packages as dependencies. diff --git a/src/_fedmod/_repodata.py b/src/_fedmod/_repodata.py index 1689aac..7ecb0a3 100644 --- a/src/_fedmod/_repodata.py +++ b/src/_fedmod/_repodata.py @@ -85,7 +85,8 @@ def _download_one_file(remote_url, filename): if os.path.exists(filename) and not filename.endswith((".xml", ".yaml")): print(f" Skipping download; {filename} already exists") return - with requests.get(remote_url, stream=True) as response: + response = requests.get(remote_url, stream=True) + try: print(f" Downloading {remote_url}") chunksize = 65536 expected_chunks = int(response.headers["content-length"]) / chunksize @@ -94,6 +95,8 @@ def _download_one_file(remote_url, filename): with show_progress: for chunk in show_progress: pass + finally: + response.close() print(f" Added {filename} to cache") def _download_metadata_files(repo_paths): diff --git a/src/setup.py b/src/setup.py index 447b4e7..5f75e3a 100644 --- a/src/setup.py +++ b/src/setup.py @@ -5,7 +5,7 @@ from setuptools import setup, find_packages setup( name='fedmod', - version='0.0.1', + version='0.0.2', author='Dominika Hodovska', author_email='dhodovsk@redhat.com', maintainer='Nick Coghlan', diff --git a/tox.ini b/tox.ini index 205c090..617e9a3 100644 --- a/tox.ini +++ b/tox.ini @@ -13,3 +13,15 @@ whitelist_externals = deps = pytest commands = pytest {posargs} + +[testenv:system] +# Run `tox -e system` to check compatibility with system versions +# of dependencies (including test dependencies) +sitepackages = True +deps = +whitelist_externals = + pytest-3 +install_command = pip install --no-deps {opts} {packages} +commands = \ + fedmod fetch-metadata + pytest-3 {posargs}