Skip to content

Commit 2e10199

Browse files
authored
Merge pull request #2054 from EliahKagan/deprecated-classifier
Fail `test_installation` on warnings, and remove deprecated license classifier
2 parents 46c439b + b21c32a commit 2e10199

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def _stamp_version(filename: str) -> None:
9595
# "Development Status :: 7 - Inactive",
9696
"Environment :: Console",
9797
"Intended Audience :: Developers",
98-
"License :: OSI Approved :: BSD License",
9998
"Operating System :: OS Independent",
10099
"Operating System :: POSIX",
101100
"Operating System :: Microsoft :: Windows",

test/test_installation.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
33

44
import ast
5+
import functools
56
import os
67
import subprocess
78

@@ -11,50 +12,22 @@
1112
class TestInstallation(TestBase):
1213
@with_rw_directory
1314
def test_installation(self, rw_dir):
14-
venv = self._set_up_venv(rw_dir)
15+
venv, run = self._set_up_venv(rw_dir)
1516

16-
result = subprocess.run(
17-
[venv.pip, "install", "."],
18-
stdout=subprocess.PIPE,
19-
cwd=venv.sources,
20-
)
21-
self.assertEqual(
22-
0,
23-
result.returncode,
24-
msg=result.stderr or result.stdout or "Can't install project",
25-
)
17+
result = run([venv.pip, "install", "."])
18+
self._check_result(result, "Can't install project")
2619

27-
result = subprocess.run(
28-
[venv.python, "-c", "import git"],
29-
stdout=subprocess.PIPE,
30-
cwd=venv.sources,
31-
)
32-
self.assertEqual(
33-
0,
34-
result.returncode,
35-
msg=result.stderr or result.stdout or "Self-test failed",
36-
)
20+
result = run([venv.python, "-c", "import git"])
21+
self._check_result(result, "Self-test failed")
3722

38-
result = subprocess.run(
39-
[venv.python, "-c", "import gitdb; import smmap"],
40-
stdout=subprocess.PIPE,
41-
cwd=venv.sources,
42-
)
43-
self.assertEqual(
44-
0,
45-
result.returncode,
46-
msg=result.stderr or result.stdout or "Dependencies not installed",
47-
)
23+
result = run([venv.python, "-c", "import gitdb; import smmap"])
24+
self._check_result(result, "Dependencies not installed")
4825

4926
# Even IF gitdb or any other dependency is supplied during development by
5027
# inserting its location into PYTHONPATH or otherwise patched into sys.path,
5128
# make sure it is not wrongly inserted as the *first* entry.
52-
result = subprocess.run(
53-
[venv.python, "-c", "import sys; import git; print(sys.path)"],
54-
stdout=subprocess.PIPE,
55-
cwd=venv.sources,
56-
)
57-
syspath = result.stdout.decode("utf-8").splitlines()[0]
29+
result = run([venv.python, "-c", "import sys; import git; print(sys.path)"])
30+
syspath = result.stdout.splitlines()[0]
5831
syspath = ast.literal_eval(syspath)
5932
self.assertEqual(
6033
"",
@@ -64,10 +37,37 @@ def test_installation(self, rw_dir):
6437

6538
@staticmethod
6639
def _set_up_venv(rw_dir):
40+
# Initialize the virtual environment.
6741
venv = VirtualEnvironment(rw_dir, with_pip=True)
42+
43+
# Make its src directory a symlink to our own top-level source tree.
6844
os.symlink(
6945
os.path.dirname(os.path.dirname(__file__)),
7046
venv.sources,
7147
target_is_directory=True,
7248
)
73-
return venv
49+
50+
# Create a convenience function to run commands in it.
51+
run = functools.partial(
52+
subprocess.run,
53+
stdout=subprocess.PIPE,
54+
stderr=subprocess.PIPE,
55+
universal_newlines=True,
56+
cwd=venv.sources,
57+
env={**os.environ, "PYTHONWARNINGS": "error"},
58+
)
59+
60+
return venv, run
61+
62+
def _check_result(self, result, failure_summary):
63+
self.assertEqual(
64+
0,
65+
result.returncode,
66+
msg=self._prepare_failure_message(result, failure_summary),
67+
)
68+
69+
@staticmethod
70+
def _prepare_failure_message(result, failure_summary):
71+
stdout = result.stdout.rstrip()
72+
stderr = result.stderr.rstrip()
73+
return f"{failure_summary}\n\nstdout:\n{stdout}\n\nstderr:\n{stderr}"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy