Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c91dc97

Browse filesBrowse files
committed
Add failed test for inherits = ".." in user-defined benchmarks.
1 parent 69f3b19 commit c91dc97
Copy full SHA for c91dc97

File tree

7 files changed

+57
-20
lines changed
Filter options

7 files changed

+57
-20
lines changed

‎pyperformance/tests/__init__.py

Copy file name to clipboardExpand all lines: pyperformance/tests/__init__.py
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
import contextlib
22
import errno
33
import os
4+
import subprocess
5+
import sys
46
import tempfile
57

8+
DATA_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), 'data'))
9+
10+
11+
def run_cmd(cmd):
12+
print("Execute: %s" % ' '.join(cmd))
13+
proc = subprocess.Popen(cmd)
14+
try:
15+
proc.wait()
16+
except: # noqa
17+
proc.kill()
18+
proc.wait()
19+
raise
20+
21+
exitcode = proc.returncode
22+
if exitcode:
23+
sys.exit(exitcode)
24+
625

726
@contextlib.contextmanager
827
def temporary_file(**kwargs):
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[benchmarks]
2+
3+
name metafile
4+
1 <local>
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[project]
2+
dynamic = ["name"]
3+
version = "1.0.0"
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[project]
2+
name = "test_bm_1"
3+
requires-python = ">=3.8"
4+
dependencies = ["pyperf"]
5+
urls = { repository = "https://github.com/python/pyperformance" }
6+
dynamic = ["version"]
7+
8+
[tool.pyperformance]
9+
name = "1"
10+
tags = "test"
11+
inherits = ".."

‎pyperformance/tests/test_compare.py

Copy file name to clipboardExpand all lines: pyperformance/tests/test_compare.py
+1-18Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,7 @@
77
import unittest
88

99
from pyperformance import tests
10-
11-
12-
DATA_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), 'data'))
13-
14-
15-
def run_cmd(cmd):
16-
print("Execute: %s" % ' '.join(cmd))
17-
proc = subprocess.Popen(cmd)
18-
try:
19-
proc.wait()
20-
except: # noqa
21-
proc.kill()
22-
proc.wait()
23-
raise
24-
25-
exitcode = proc.returncode
26-
if exitcode:
27-
sys.exit(exitcode)
10+
from pyperformance.tests import run_cmd, DATA_DIR
2811

2912

3013
class CompareTests(unittest.TestCase):
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os.path
2+
import sys
3+
import unittest
4+
5+
from pyperformance.tests import DATA_DIR, run_cmd
6+
7+
USER_DEFINED_MANIFEST = os.path.join(DATA_DIR, 'user_defined_bm', 'MANIFEST')
8+
9+
10+
class TestBM(unittest.TestCase):
11+
def test_user_defined_bm(self):
12+
cmd = [sys.executable, '-m', 'pyperformance', 'run', f'--manifest={USER_DEFINED_MANIFEST}']
13+
14+
run_cmd(cmd)
15+
16+
17+
if __name__ == "__main__":
18+
unittest.main()

‎runtests.py

Copy file name to clipboardExpand all lines: runtests.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ def run_bench(*cmd):
7777

7878
def main():
7979
# Unit tests
80-
cmd = [sys.executable, '-u',
81-
os.path.join('pyperformance', 'tests', 'test_compare.py')]
80+
cmd = [sys.executable, '-u', '-m', 'unittest']
8281
run_cmd(cmd)
8382

8483
# Functional tests

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.