Browse Source

permit execution of tests with optimization set

- all tests except object tests now run with PYTHONOPTIMIZE=2
The MMGen Project 3 years ago
parent
commit
b995cbf71e
4 changed files with 16 additions and 0 deletions
  1. 5 0
      test/test-release.sh
  2. 5 0
      test/test_py_d/ts_misc.py
  3. 3 0
      test/test_py_d/ts_regtest.py
  4. 3 0
      test/unit_tests.py

+ 5 - 0
test/test-release.sh

@@ -257,6 +257,11 @@ t_obj="
 "
 f_obj='Data object tests completed'
 
+[ "$PYTHONOPTIMIZE" ] && {
+	echo -e "${YELLOW}PYTHONOPTIMIZE set, skipping object tests$RESET"
+	t_obj_skip='-'
+}
+
 i_color='Color'
 s_color='Testing terminal colors'
 t_color="- $colortest_py"

+ 5 - 0
test/test_py_d/ts_misc.py

@@ -79,6 +79,11 @@ class TestSuiteHelp(TestSuiteBase):
 					'txsign','txdo','txbump'))
 
 	def tool_help(self):
+
+		if os.getenv('PYTHONOPTIMIZE') == '2':
+			ymsg('Skipping tool help with PYTHONOPTIMIZE=2 (no docstrings)')
+			return 'skip'
+
 		for args in (
 			['--help'],
 			['--longhelp'],

+ 3 - 0
test/test_py_d/ts_regtest.py

@@ -900,6 +900,9 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
 		return self._user_chk_label('alice',mmid,'Label added using coin address of MMGen address')
 
 	def alice_add_label_badaddr(self,addr,reply):
+		if os.getenv('PYTHONOPTIMIZE'):
+			omsg(yellow(f'PYTHONOPTIMIZE set, skipping test {self.test_name!r}'))
+			return 'skip'
 		t = self.spawn('mmgen-tool',['--alice','add_label',addr,'(none)'])
 		t.expect(reply,regex=True)
 		return t

+ 3 - 0
test/unit_tests.py

@@ -75,6 +75,9 @@ class UnitTestHelpers(object):
 
 	@classmethod
 	def process_bad_data(cls,data):
+		if os.getenv('PYTHONOPTIMIZE'):
+			ymsg('PYTHONOPTIMIZE set, skipping error handling tests')
+			return
 		import re
 		desc_w = max(len(e[0]) for e in data)
 		exc_w = max(len(e[1]) for e in data)