예제 #1
0
 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'])
예제 #2
0
 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'])
예제 #3
0
 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'])
예제 #4
0
 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"])
예제 #5
0
 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")
예제 #6
0
 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')
예제 #7
0
 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')
예제 #8
0
 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, '~/')
예제 #9
0
 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, '~/')
예제 #10
0
 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, "~/")
예제 #11
0
 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')
예제 #12
0
 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")
예제 #13
0
 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')
예제 #14
0
 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'é')
예제 #15
0
    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'é')
예제 #16
0
 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")
예제 #17
0
 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")
예제 #18
0
 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')
예제 #19
0
 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')
예제 #20
0
 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")
예제 #21
0
 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')
예제 #22
0
 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')
예제 #23
0
 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")
예제 #24
0
 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')