def test_unicode(self): """A non-ascii variable is returned as unicode""" unicode_val = u"\xa7" # non-ascii character present in many encodings try: bytes_val = unicode_val.encode(osutils.get_user_encoding()) except UnicodeEncodeError: self.skip("Couldn't encode non-ascii string to place in environ") os.environ["TEST"] = bytes_val self.assertEqual(unicode_val, win32utils.get_environ_unicode("TEST"))
def test_long(self): """A variable bigger than heuristic buffer size is still accessible""" big_val = "x" * (2<<10) os.environ["TEST"] = big_val self.assertEqual(big_val, win32utils.get_environ_unicode("TEST"))
def test_unset_default(self): """A variable not present in the environment gives passed default""" del os.environ["TEST"] self.assertIs("a", win32utils.get_environ_unicode("TEST", "a"))
def test_unset(self): """A variable not present in the environment gives None by default""" del os.environ["TEST"] self.assertIs(None, win32utils.get_environ_unicode("TEST"))
def test_get(self): """In the normal case behaves the same as os.environ access""" self.assertEqual("1", win32utils.get_environ_unicode("TEST"))