def test_true_type(self): for value in ("1", "yes", "true", "on", "YES", "TRUE", "ON"): @register() class config: foo = False os.environ['FOO'] = value self.parse_with_envvars() assert config.foo is True discard()
def test_false_type(self): for value in ("0", "no", "false", "off", "NO", "FALSE", "OFF"): @register('name') class config: foo = True os.environ['FOO'] = value self.parse_with_envvars() assert config.foo is False discard()
def test_false_type(self): for value in ("0", "no", "false", "off", "NO", "FALSE", "OFF"): @register('name') class config: foo = True self.write_to_file(textwrap.dedent(""" [name] foo = %s """ % (value))) self.parse(self.TESTFN) assert config.foo is False discard()
def test_true_type(self): for value in ("1", "yes", "true", "on", "YES", "TRUE", "ON"): @register('name') class config: foo = False self.write_to_file(textwrap.dedent(""" [name] foo = %s """ % (value))) self.parse(self.TESTFN) assert config.foo is True discard()
def test_false(self): @register('name') class config: foo = None bar = 2 true_values = ("0", "no", "false", "off") for value in true_values: self.write_to_file(textwrap.dedent(""" [name] foo = %s """ % (value))) parse(self.TESTFN) self.assertEqual(config.foo, False) discard()
def test_mro(self): # This method is automatically added by the meta class wrapper: # https://docs.python.org/3/library/stdtypes.html#class.mro # Make sure we can override it. @register() class config: mro = 2 assert config.mro == 2 discard() @register() class config: pass config.mro
def tearDown(self): discard() os.environ = self.original_environ if getattr(self, 'TESTFN', None) is not None: safe_remove(self.TESTFN)
def setUp(self): discard() self.original_environ = os.environ.copy() if getattr(self, 'TESTFN', None) is not None: safe_remove(self.TESTFN)
def tearDown(self): discard() unlink(self.TESTFN)