Skip to content

Commit b9890ea

Browse files
authored
Merge pull request #65 from lpsinger/test-executable-name
Don't assume pytest executable is called py.test in unit tests
2 parents 7a64a1f + ecc0d68 commit b9890ea

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/test_pytest_mpl.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ def test_fails(tmpdir):
8686
f.write(TEST_FAILING)
8787

8888
# If we use --mpl, it should detect that the figure is wrong
89-
code = subprocess.call('py.test --mpl {0}'.format(test_file), shell=True)
89+
code = subprocess.call('{0} -m pytest --mpl {1}'.format(sys.executable, test_file), shell=True)
9090
assert code != 0
9191

9292
# If we don't use --mpl option, the test should succeed
93-
code = subprocess.call('py.test {0}'.format(test_file), shell=True)
93+
code = subprocess.call('{0} -m pytest {1}'.format(sys.executable, test_file), shell=True)
9494
assert code == 0
9595

9696

@@ -113,7 +113,7 @@ def test_output_dir(tmpdir):
113113

114114
# When we run the test, we should get output images where we specify
115115
output_dir = tmpdir.join('test_output_dir').strpath
116-
code = subprocess.call('py.test --mpl-results-path={0} --mpl {1}'.format(output_dir, test_file),
116+
code = subprocess.call('{0} -m pytest --mpl-results-path={1} --mpl {2}'.format(sys.executable, output_dir, test_file),
117117
shell=True)
118118

119119
assert code != 0
@@ -150,13 +150,13 @@ def test_generate(tmpdir):
150150
gen_dir = tmpdir.mkdir('spam').mkdir('egg').strpath
151151

152152
# If we don't generate, the test will fail
153-
p = subprocess.Popen('py.test --mpl {0}'.format(test_file), shell=True,
153+
p = subprocess.Popen('{0} -m pytest --mpl {1}'.format(sys.executable, test_file), shell=True,
154154
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
155155
p.wait()
156156
assert b'Image file not found for comparison test' in p.stdout.read()
157157

158158
# If we do generate, the test should succeed and a new file will appear
159-
code = subprocess.call('py.test --mpl-generate-path={0} {1}'.format(gen_dir, test_file), shell=True)
159+
code = subprocess.call('{0} -m pytest --mpl-generate-path={1} {2}'.format(sys.executable, gen_dir, test_file), shell=True)
160160
assert code == 0
161161
assert os.path.exists(os.path.join(gen_dir, 'test_gen.png'))
162162

0 commit comments

Comments
 (0)