From a3efb5b2a082ebabbea74a04788aec2a82e26927 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Mon, 25 Jul 2022 08:50:20 +0100 Subject: [PATCH] Reveal and fix a masked test (#1671) * DEV: Reveal a masked test method the test method started with an underscore which is why unittest wasnt discovering it modified: traits/etsconfig/tests/test_etsconfig.py * FIX: Update the app_name and get the test passing we are making a strong assumption here that the tests are being run using unittest modified: traits/etsconfig/tests/test_etsconfig.py * CLN: Remove the now unnecessary dundername/dundermain clause modified: traits/etsconfig/tests/test_etsconfig.py (cherry picked from commit f379908b01cacc2e57edea2531817acc4732ef91) --- traits/etsconfig/tests/test_etsconfig.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/traits/etsconfig/tests/test_etsconfig.py b/traits/etsconfig/tests/test_etsconfig.py index 9c1b3d78f..271f6dc46 100644 --- a/traits/etsconfig/tests/test_etsconfig.py +++ b/traits/etsconfig/tests/test_etsconfig.py @@ -202,20 +202,19 @@ def test_set_company(self): self.ETSConfig.company = old self.assertEqual(old, self.ETSConfig.company) - def _test_default_application_home(self): + def test_default_application_home(self): """ application home """ - - # This test is only valid when run with the 'main' at the end of this - # file: "python app_dat_locator_test_case.py", in which case the - # app_name will be the directory this file is in ('tests'). app_home = self.ETSConfig.application_home (dirname, app_name) = os.path.split(app_home) self.assertEqual(dirname, self.ETSConfig.application_data) - self.assertEqual(app_name, "tests") + + # The assumption here is that the test was run using unittest and not + # a different test runner e.g. using "python -m unittest ...". + self.assertEqual(app_name, "unittest") def test_toolkit_default_kiva_backend(self): self.ETSConfig.toolkit = "qt4" @@ -363,14 +362,3 @@ def test_write_to_user_data_directory(self): os.remove(path) self.assertEqual(data, result) - - -# For running as an individual set of tests. -if __name__ == "__main__": - - # Add the non-default test of application_home...non-default because it - # must be run using this module as a script to be valid. - suite = unittest.TestLoader().loadTestsFromTestCase(ETSConfigTestCase) - suite.addTest(ETSConfigTestCase("_test_default_application_home")) - - unittest.TextTestRunner(verbosity=2).run(suite)