Skip to content

Commit e47032f

Browse files
Merge pull request RustPython#749 from adrian17/tests-cleanup
Tests cleanups
2 parents 9989795 + 2131a81 commit e47032f

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

tests/snippets/append.py

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

tests/snippets/strings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from testutils import assert_raises
2+
13
assert "a" == 'a'
24
assert """a""" == "a"
35
assert len(""" " "" " "" """) == 11
@@ -124,3 +126,9 @@
124126
assert 'z' > 'b'
125127
assert 'z' >= 'b'
126128
assert 'a' >= 'a'
129+
130+
def try_mutate_str():
131+
word = "word"
132+
word[0] = 'x'
133+
134+
assert_raises(TypeError, try_mutate_str)

tests/snippets/xfail_3.1.2.17.py

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

tests/test_snippets.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717

1818
class _TestType(enum.Enum):
1919
functional = 1
20-
benchmark = 2
2120

2221

2322
logger = logging.getLogger('tests')
2423
ROOT_DIR = '..'
2524
TEST_ROOT = os.path.abspath(os.path.join(ROOT_DIR, 'tests'))
2625
TEST_DIRS = {
2726
_TestType.functional: os.path.join(TEST_ROOT, 'snippets'),
28-
_TestType.benchmark: os.path.join(TEST_ROOT, 'benchmarks'),
2927
}
3028
CPYTHON_RUNNER_DIR = os.path.abspath(os.path.join(ROOT_DIR, 'py_code_object'))
3129
RUSTPYTHON_RUNNER_DIR = os.path.abspath(os.path.join(ROOT_DIR))
@@ -65,24 +63,23 @@ def run_via_cpython_bytecode(filename, test_type):
6563

6664
# Step2: run cpython bytecode:
6765
env = os.environ.copy()
68-
log_level = 'info' if test_type == _TestType.benchmark else 'debug'
69-
env['RUST_LOG'] = '{},cargo=error,jobserver=error'.format(log_level)
66+
env['RUST_LOG'] = 'info,cargo=error,jobserver=error'
7067
env['RUST_BACKTRACE'] = '1'
7168
with pushd(CPYTHON_RUNNER_DIR):
7269
subprocess.check_call(['cargo', 'run', bytecode_filename], env=env)
7370

7471

7572
def run_via_rustpython(filename, test_type):
7673
env = os.environ.copy()
77-
log_level = 'info' if test_type == _TestType.benchmark else 'trace'
78-
env['RUST_LOG'] = '{},cargo=error,jobserver=error'.format(log_level)
74+
env['RUST_LOG'] = 'info,cargo=error,jobserver=error'
7975
env['RUST_BACKTRACE'] = '1'
76+
77+
target = 'release'
8078
if env.get('CODE_COVERAGE', 'false') == 'true':
81-
subprocess.check_call(
82-
['cargo', 'run', filename], env=env)
83-
else:
84-
subprocess.check_call(
85-
['cargo', 'run', '--release', filename], env=env)
79+
target = 'debug'
80+
binary = os.path.abspath(os.path.join(ROOT_DIR, 'target', target, 'rustpython'))
81+
82+
subprocess.check_call([binary, filename], env=env)
8683

8784

8885
def create_test_function(cls, filename, method, test_type):
@@ -124,4 +121,7 @@ def get_test_files():
124121
# @populate('cpython_bytecode')
125122
@populate('rustpython')
126123
class SampleTestCase(unittest.TestCase):
127-
pass
124+
@classmethod
125+
def setUpClass(cls):
126+
subprocess.check_call(['cargo', 'build'])
127+
subprocess.check_call(['cargo', 'build', '--release'])

0 commit comments

Comments
 (0)