예제 #1
0
    def test_non_dict_items(self):
        class NonDictItems(object):
            def items(self):
                yield (u"e", u"f")
                yield (u"g", u"h")

        self.assertEqual(_environment_to_string(NonDictItems()),
                         u"e=f\0g=h\0\0")
예제 #2
0
    def test_non_dict_iteritems(self):
        class NonDictIterItems(object):
            def iteritems(self):
                yield (u"a", u"b")
                yield (u"c", u"d")

        self.assertEqual(_environment_to_string(NonDictIterItems()),
                         u"a=b\0c=d\0\0")
예제 #3
0
    def test_non_dict_items(self):
        class NonDictItems(object):
            def items(self):
                yield (u"e", u"f")
                yield (u"g", u"h")

        self.assertEqual(
            _environment_to_string(NonDictItems()),
            u"e=f\0g=h\0\0")
예제 #4
0
    def test_non_dict_iteritems(self):
        class NonDictIterItems(object):
            def iteritems(self):
                yield (u"a", u"b")
                yield (u"c", u"d")

        self.assertEqual(
            _environment_to_string(NonDictIterItems()),
            u"a=b\0c=d\0\0")
예제 #5
0
 def test_not_a_dictionary(self):
     expected = "Expected a dictionary like object for `environment`"
     with self.assertRaisesRegex(InputError, expected):
         _environment_to_string(None)
예제 #6
0
 def test_key_cannot_contain_equals(self):
     with self.assertRaisesRegex(InputError, ".*cannot contain the `=`.*"):
         _environment_to_string({text_type("3=4"): text_type("")})
예제 #7
0
 def test_type_check_for_environment_value(self):
     with self.assertRaisesRegex(InputError, ".*environment value 2.*"):
         _environment_to_string({text_type("1"): 2})
예제 #8
0
 def test_type_check_for_environment_key(self):
     with self.assertRaises(InputError):
         _environment_to_string({1: text_type("")})
예제 #9
0
 def test_not_a_dictionary(self):
     expected = "Expected a dictionary like object for `environment`"
     with self.assertRaisesRegex(InputError, expected):
         _environment_to_string(None)
예제 #10
0
 def test_key_cannot_contain_equals(self):
     with self.assertRaisesRegex(InputError, ".*cannot contain the `=`.*"):
         _environment_to_string({u"3=4": u""})
예제 #11
0
 def test_type_check_for_environment_value(self):
     with self.assertRaisesRegex(InputError, ".*environment value 2.*"):
         _environment_to_string({u"1": 2})
예제 #12
0
 def test_type_check_for_environment_key(self):
     with self.assertRaises(InputError):
         _environment_to_string({1: u""})