git.iko.soy/typeable/nixpkgs
on master help sign in
pythonPackages.astroquery: add checkPhase
commit1354a2e642d597c5263084594ff36ce7abcf006c authorSébastien Maret <sebastien.maret@icloud.com> dateTue 23 Jul 2019, 18:44 (7 years ago) parent93a6bba
2 files changed+77−2
pkgs/development/python-modules/astroquery/conftest-astropy-3-fix.patch+54 pkgs/development/python-modules/astroquery/default.nix+23−2
pkgs/development/python-modules/astroquery/conftest-astropy-3-fix.patchnew file+54
@@ -0,0 +1,54 @@
1+diff -ruN astroquery-0.3.9.orig/astroquery/conftest.py astroquery-0.3.9/astroquery/conftest.py
2+--- astroquery-0.3.9.orig/astroquery/conftest.py 2018-11-27 14:51:16.000000000 +0100
3++++ astroquery-0.3.9/astroquery/conftest.py 2019-07-23 18:19:17.000000000 +0200
4+@@ -5,15 +5,20 @@
5+ # by importing them here in conftest.py they are discoverable by py.test
6+ # no matter how it is invoked within the source tree.
7+
8+-from astropy.tests.pytest_plugins import (PYTEST_HEADER_MODULES,
9+- enable_deprecations_as_exceptions,
10+- TESTED_VERSIONS)
11++from astropy.version import version as astropy_version
12+
13+-try:
14+- packagename = os.path.basename(os.path.dirname(__file__))
15+- TESTED_VERSIONS[packagename] = version.version
16+-except NameError:
17+- pass
18++if astropy_version < '3.0':
19++ # With older versions of Astropy, we actually need to import the pytest
20++ # plugins themselves in order to make them discoverable by pytest.
21++ from astropy.tests.pytest_plugins import *
22++else:
23++ # As of Astropy 3.0, the pytest plugins provided by Astropy are
24++ # automatically made available when Astropy is installed. This means it's
25++ # not necessary to import them here, but we still need to import global
26++ # variables that are used for configuration.
27++ from astropy.tests.plugins.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS
28++
29++from astropy.tests.helper import enable_deprecations_as_exceptions
30+
31+ # Add astropy to test header information and remove unused packages.
32+ # Pytest header customisation was introduced in astropy 1.0.
33+@@ -36,12 +41,17 @@
34+ # The warnings_to_ignore_by_pyver parameter was added in astropy 2.0
35+ enable_deprecations_as_exceptions(modules_to_ignore_on_import=['requests'])
36+
37++# add '_testrun' to the version name so that the user-agent indicates that
38++# it's being run in a test
39++from . import version
40++version.version += '_testrun'
41++
42++
43+ # This is to figure out the affiliated package version, rather than
44+ # using Astropy's
45+-try:
46+- from .version import version
47+-except ImportError:
48+- version = 'dev'
49++from .version import version, astropy_helpers_version
50++
51+
52+ packagename = os.path.basename(os.path.dirname(__file__))
53+ TESTED_VERSIONS[packagename] = version
54++TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version
pkgs/development/python-modules/astroquery/default.nix+23−2
@@ -6,21 +6,42 @@
66, keyring
77, beautifulsoup4
88, html5lib
9+, pytest
10+, pytest-astropy
11+, astropy-helpers
912}:
1013
1114buildPythonPackage rec {
1215 pname = "astroquery";
1316 version = "0.3.9";
1417
15− doCheck = false; # Tests require the pytest-astropy package
16−
1718 src = fetchPypi {
1819 inherit pname version;
1920 sha256 = "0zw3xp2rfc6h2v569iqsyvzhfnzp7bfjb7jrj61is1hrqw1cqjrb";
2021 };
2122
23+ # Fix tests using conftest.py from HEAD in the upstream GitHub
24+ # repository.
25+ patches = [ ./conftest-astropy-3-fix.patch ];
26+
2227 propagatedBuildInputs = [ astropy requests keyring beautifulsoup4 html5lib ];
2328
29+ nativeBuildInputs = [ astropy-helpers ];
30+
31+ checkInputs = [ pytest pytest-astropy ];
32+
33+ # Disable automatic update of the astropy-helper module
34+ postPatch = ''
35+ substituteInPlace setup.cfg --replace "auto_use = True" "auto_use = False"
36+ '';
37+
38+ # Tests must be run in the build directory. The tests create files
39+ # in $HOME/.astropy so we need to set HOME to $TMPDIR.
40+ checkPhase = ''
41+ cd build/lib
42+ HOME=$TMPDIR pytest
43+ '';
44+
2445 meta = with pkgs.lib; {
2546 description = "Functions and classes to access online data resources";
2647 homepage = "https://astroquery.readthedocs.io/";