def test_extra_args(self): cl = self.klass() with mute_warn(): config = cl.load_config(['--a=5', 'b', '--c=10', 'd']) self.assertEqual(cl.extra_args, ['b', 'd']) self.assertEqual(config.a, 5) self.assertEqual(config.c, 10) with mute_warn(): config = cl.load_config(['--', '--a=5', '--c=10']) self.assertEqual(cl.extra_args, ['--a=5', '--c=10'])
def test_extra_args(self): cl = KeyValueConfigLoader() with mute_warn(): config = cl.load_config(['--a=5', 'b', '--c=10', 'd']) self.assertEquals(cl.extra_args, ['b', 'd']) self.assertEquals(config.a, 5) self.assertEquals(config.c, 10) with mute_warn(): config = cl.load_config(['--', '--a=5', '--c=10']) self.assertEquals(cl.extra_args, ['--a=5', '--c=10'])
def test_extra_args(self): cl = self.klass() with mute_warn(): config = cl.load_config(["--a=5", "b", "--c=10", "d"]) self.assertEqual(cl.extra_args, ["b", "d"]) self.assertEqual(config.a, 5) self.assertEqual(config.c, 10) with mute_warn(): config = cl.load_config(["--", "--a=5", "--c=10"]) self.assertEqual(cl.extra_args, ["--a=5", "--c=10"])
def test_expanduser2(self): cl = self.klass() argv = ["-a", "~/1/2/3", "--b", "'~/1/2/3'"] with mute_warn(): config = cl.load_config(argv, aliases=dict(a="A.a", b="A.b")) self.assertEqual(config.A.a, os.path.expanduser("~/1/2/3")) self.assertEqual(config.A.b, "~/1/2/3")
def test_expanduser2(self): cl = self.klass() argv = ['-a', '~/1/2/3', '--b', "'~/1/2/3'"] with mute_warn(): config = cl.load_config(argv, aliases=dict(a='A.a', b='A.b')) self.assertEqual(config.A.a, os.path.expanduser('~/1/2/3')) self.assertEqual(config.A.b, '~/1/2/3')
def test_expanduser(self): cl = self.klass() argv = ['--a=~/1/2/3', '--b=~', '--c=~/', '--d="~/"'] with mute_warn(): config = cl.load_config(argv) self.assertEqual(config.a, os.path.expanduser('~/1/2/3')) self.assertEqual(config.b, os.path.expanduser('~')) self.assertEqual(config.c, os.path.expanduser('~/')) self.assertEqual(config.d, '~/')
def test_expanduser(self): cl = self.klass() argv = ["--a=~/1/2/3", "--b=~", "--c=~/", '--d="~/"'] with mute_warn(): config = cl.load_config(argv) self.assertEqual(config.a, os.path.expanduser("~/1/2/3")) self.assertEqual(config.b, os.path.expanduser("~")) self.assertEqual(config.c, os.path.expanduser("~/")) self.assertEqual(config.d, "~/")
def test_basic(self): cl = self.klass() argv = ['--' + s.strip('c.') for s in pyfile.split('\n')[2:-1]] with mute_warn(): config = cl.load_config(argv) self.assertEqual(config.a, 10) self.assertEqual(config.b, 20) self.assertEqual(config.Foo.Bar.value, 10) self.assertEqual(config.Foo.Bam.value, range(10)) self.assertEqual(config.D.C.value, 'hi there')
def test_basic(self): cl = self.klass() argv = ["--" + s.strip("c.") for s in pyfile.split("\n")[2:-1]] with mute_warn(): config = cl.load_config(argv) self.assertEqual(config.a, 10) self.assertEqual(config.b, 20) self.assertEqual(config.Foo.Bar.value, 10) self.assertEqual(config.Foo.Bam.value, range(10)) self.assertEqual(config.D.C.value, "hi there")
def test_basic(self): cl = self.klass() argv = ['--'+s.strip('c.') for s in pyfile.split('\n')[2:-1]] with mute_warn(): config = cl.load_config(argv) self.assertEqual(config.a, 10) self.assertEqual(config.b, 20) self.assertEqual(config.Foo.Bar.value, 10) self.assertEqual(config.Foo.Bam.value, range(10)) self.assertEqual(config.D.C.value, 'hi there')
def test_unicode_bytes_args(self): uarg = u'--a=é' try: barg = uarg.encode(sys.stdin.encoding) except (TypeError, UnicodeEncodeError): raise SkipTest("sys.stdin.encoding can't handle 'é'") cl = self.klass() with mute_warn(): config = cl.load_config([barg]) self.assertEqual(config.a, u'é')
def test_eval(self): cl = self.klass() argv = ['-c', 'a=5'] with mute_warn(): config = cl.load_config(argv, aliases=dict(c='A.c')) self.assertEqual(config.A.c, u"a=5")
def test_unicode_alias(self): cl = self.klass() argv = [u"--a=épsîlön"] with mute_warn(): config = cl.load_config(argv, aliases=dict(a="A.a")) self.assertEqual(config.A.a, u"épsîlön")
def test_unicode_alias(self): cl = self.klass() argv = [u'--a=épsîlön'] with mute_warn(): config = cl.load_config(argv, aliases=dict(a='A.a')) self.assertEqual(config.A.a, u'épsîlön')
def test_unicode_args(self): cl = self.klass() argv = [u'--a=épsîlön'] with mute_warn(): config = cl.load_config(argv) self.assertEqual(config.a, u'épsîlön')
def test_eval(self): cl = self.klass() argv = ["-c", "a=5"] with mute_warn(): config = cl.load_config(argv, aliases=dict(c="A.c")) self.assertEqual(config.A.c, u"a=5")
def test_unicode_args(self): cl = KeyValueConfigLoader() argv = [u'--a=épsîlön'] with mute_warn(): config = cl.load_config(argv) self.assertEquals(config.a, u'épsîlön')