Skip to content

Commit d0d4e44

Browse files
committed
Restore the test_requirements.txt file
I have adjusted setup.py to read test requirements from this file instead.
1 parent f5633ad commit d0d4e44

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

setup.py

+14-11
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,25 @@
2929

3030
directory = os.path.abspath(os.path.dirname(__file__))
3131
path = os.path.join(directory, "version.txt")
32-
version_string = open(path).readline()
32+
with open(path) as f:
33+
version_string = f.readline()
3334
match = re.match(r"\s*(?P<rel>(?P<ver>\d+\.\d+)(?:\.\S+)*)\s*", version_string)
3435
version = match.group("ver")
3536
release = match.group("rel")
3637

38+
#---------------------------------------------------------------------------
39+
# Gather test requirements from the 'test_requirements.txt' file.
40+
# This is to allow installing test requirements with the following command:
41+
# pip install dragonfly[test].
42+
43+
def read(name):
44+
with open(os.path.join(os.path.dirname(__file__), name)) as f:
45+
return f.read()
46+
47+
test_requirements = read("test_requirements.txt").split("\n")[:-1]
48+
3749
#---------------------------------------------------------------------------
3850
# Override the 'test' command to use pytest instead.
39-
# Test requirements are located in the 'test_requirements.txt' file.
4051

4152
class test(Command):
4253
description = 'run unit tests and doctests after in-place build'
@@ -97,14 +108,9 @@ def _try_local_natlink_pyd(self):
97108
# module to sys.modules.
98109
if natlink: sys.modules["natlink"] = natlink
99110

100-
101111
#---------------------------------------------------------------------------
102112
# Set up package.
103113

104-
def read(*names):
105-
return open(os.path.join(os.path.dirname(__file__), *names)).read()
106-
107-
108114
setup(
109115
name = "dragonfly",
110116
version = release,
@@ -140,10 +146,7 @@ def read(*names):
140146
],
141147

142148
extras_require={
143-
"test": [
144-
"pytest == 3.9.*;python_version<'3.8'",
145-
"pytest == 7.4.*;python_version>='3.8'",
146-
],
149+
"test": test_requirements,
147150
"accessibility": [
148151
"comtypes;platform_system=='Windows'",
149152
"enum34;python_version<'3.4'",

test_requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest == 3.9.*;python_version<'3.8'
2+
pytest == 7.4.*;python_version>='3.8'

0 commit comments

Comments
 (0)