Skip to content

Commit 6c092b9

Browse files
authored
Merge branch 'main' into loaddata_headers
2 parents 97a4f70 + 57bad6e commit 6c092b9

File tree

6 files changed

+31
-141
lines changed

6 files changed

+31
-141
lines changed

.travis.yml

Lines changed: 0 additions & 115 deletions
This file was deleted.

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.. image:: https://travis-ci.org/diffpy/diffpy.utils.svg?branch=master
2-
:target: https://travis-ci.org/diffpy/diffpy.utils
1+
.. image:: https://github.com/diffpy/diffpy.utils/actions/workflows/main.yml/badge.svg
2+
:target: https://github.com/diffpy/diffpy.utils/actions/workflows/main.yml
33

4-
.. image:: https://codecov.io/gh/diffpy/diffpy.utils/branch/master/graph/badge.svg
4+
.. image:: https://codecov.io/gh/diffpy/diffpy.utils/branch/main/graph/badge.svg
55
:target: https://codecov.io/gh/diffpy/diffpy.utils
66

77

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[pytest]
22
testpaths= src/diffpy/utils/tests
3-
python_files = test*.py
3+
python_files = test_*.py

src/diffpy/utils/tests/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ def testsuite(pattern=''):
3737
import re
3838
from os.path import dirname
3939
from itertools import chain
40-
from pkg_resources import resource_filename
40+
from importlib.resources import files, as_file
4141
loader = unittest.defaultTestLoader
42-
thisdir = resource_filename(__name__, '')
43-
depth = __name__.count('.') + 1
44-
topdir = thisdir
45-
for i in range(depth):
46-
topdir = dirname(topdir)
47-
suite_all = loader.discover(thisdir, top_level_dir=topdir)
42+
ref = files(__package__)
43+
with as_file(ref) as thisdir:
44+
depth = __name__.count('.') + 1
45+
topdir = thisdir
46+
for i in range(depth):
47+
topdir = dirname(topdir)
48+
suite_all = loader.discover(str(thisdir), top_level_dir=topdir)
4849
# always filter the suite by pattern to test-cover the selection code.
4950
suite = unittest.TestSuite()
5051
rx = re.compile(pattern)

src/diffpy/utils/tests/testhelpers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
# helper functions
2020

2121
def datafile(filename):
22-
from pkg_resources import resource_filename
23-
rv = resource_filename(__name__, "testdata/" + filename)
24-
return rv
22+
from importlib.resources import files, as_file
23+
ref = files(__package__) / ("testdata/" + filename)
24+
with as_file(ref) as rv:
25+
return rv
2526

2627
# End of file

src/diffpy/utils/version.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,24 @@
2626

2727
import os.path
2828

29-
from pkg_resources import resource_filename
29+
from importlib.resources import files, as_file
3030

3131

3232
# obtain version information from the version.cfg file
3333
cp = dict(version='', date='', commit='', timestamp='0')
34-
fcfg = resource_filename(__name__, 'version.cfg')
35-
if not os.path.isfile(fcfg): # pragma: no cover
36-
from warnings import warn
37-
warn('Package metadata not found, execute "./setup.py egg_info".')
38-
fcfg = os.devnull
39-
with open(fcfg) as fp:
40-
kwords = [[w.strip() for w in line.split(' = ', 1)]
41-
for line in fp if line[:1].isalpha() and ' = ' in line]
42-
assert all(w[0] in cp for w in kwords), "received unrecognized keyword"
43-
cp.update(kwords)
34+
if __package__ is not None:
35+
ref = files(__package__) / 'version.cfg'
36+
with as_file(ref) as fcfg:
37+
if not os.path.isfile(fcfg): # pragma: no cover
38+
from warnings import warn
39+
warn('Package metadata not found, execute "./setup.py egg_info".')
40+
fcfg = os.devnull
41+
with open(fcfg) as fp:
42+
kwords = [[w.strip() for w in line.split(' = ', 1)]
43+
for line in fp if line[:1].isalpha() and ' = ' in line]
44+
assert all(w[0] in cp for w in kwords), "received unrecognized keyword"
45+
cp.update(kwords)
46+
del kwords
4447

4548
__version__ = cp['version']
4649
__date__ = cp['date']
@@ -50,6 +53,6 @@
5053
# TODO remove deprecated __gitsha__ in version 3.1.
5154
__gitsha__ = __git_commit__
5255

53-
del cp, fcfg, fp, kwords
56+
del cp
5457

5558
# End of file

0 commit comments

Comments
 (0)