Skip to content

Commit

Permalink
Reveal and fix a masked test (#1671)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Poruri Sai Rahul committed Jul 25, 2022
1 parent d10d7ad commit f379908
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions traits/etsconfig/tests/test_etsconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

0 comments on commit f379908

Please sign in to comment.