Skip to content

Commit dfacb07

Browse files
authored
Merge pull request #1084 from AntelopeIO/GH-1079-http-api-test
Test: plugin_http_api_test correctly handle keeping logs when a test fails
2 parents 9a8dad3 + 708cfd5 commit dfacb07

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tests/plugin_http_api_test.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,10 +1619,7 @@ def setUpClass(self):
16191619

16201620
@classmethod
16211621
def tearDownClass(self):
1622-
global keepLogs
16231622
self.killNodes(self)
1624-
if unittest.TestResult().wasSuccessful() and not keepLogs:
1625-
self.cleanEnv(self)
16261623

16271624

16281625
if __name__ == "__main__":
@@ -1634,9 +1631,13 @@ def tearDownClass(self):
16341631
parser.add_argument('unittest_args', nargs=argparse.REMAINDER)
16351632

16361633
args = parser.parse_args()
1637-
global keepLogs
1638-
keepLogs = args.keep_logs;
1634+
keepLogs = args.keep_logs
16391635

16401636
# Now set the sys.argv to the unittest_args (leaving sys.argv[0] alone)
16411637
sys.argv[1:] = args.unittest_args
1642-
unittest.main()
1638+
suite = unittest.TestLoader().loadTestsFromTestCase(PluginHttpTest)
1639+
results = unittest.TextTestRunner().run(suite)
1640+
if not results.wasSuccessful():
1641+
keepLogs = True
1642+
if not keepLogs:
1643+
PluginHttpTest().cleanEnv()

0 commit comments

Comments
 (0)