Skip to content

Commit

Permalink
Add tests for six.environ
Browse files Browse the repository at this point in the history
  • Loading branch information
abadger committed Sep 14, 2018
1 parent 6f5915a commit 74ba4a0
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test_six.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,3 +990,56 @@ def test_ensure_text(self):
assert converted_unicode == self.UNICODE_EMOJI and isinstance(converted_unicode, str)
# PY3: bytes -> str
assert converted_binary == self.UNICODE_EMOJI and isinstance(converted_unicode, str)


class EnvironTests:

# grinning face emoji
UNICODE_EMOJI = six.u("\U0001F600")
BINARY_EMOJI = b"\xf0\x9f\x98\x80"

def test_set_environ(self):
try:
del six.environ['_six_test']
except KeyError:
pass

six.environ['_six_test'] = UNICODE_EMOJI

assert six.environ['_six_test'] == UNICODE_EMOJI
assert six.environb['_six_test'] == BINARY_EMOJI
if PY3:
assert os.environ == UNICODE_EMOJI
else:
assert os.environ == BINARY_EMOJI

del six.environ['_six_test']

def test_set_environb(self):
try:
del six.environ['_six_test']
except KeyError:
pass

six.environb['_six_test'] = BINARY_EMOJI

assert six.environ['_six_test'] == UNICODE_EMOJI
assert six.environb['_six_test'] == BINARY_EMOJI
if PY3:
assert os.environ == UNICODE_EMOJI
else:
assert os.environ == BINARY_EMOJI

del six.environ['_six_test']

def test_del_environ(self):
six.environ['_six_test'] = 'testing'
assert '_six_test' in os.environ
del six.environ['_six_test']
assert '_six_test' not in os.environ

def test_del_environb(self):
six.environb['_six_test'] = 'testing'
assert '_six_test' in os.environ
del six.environb['_six_test']
assert '_six_test' not in os.environ

0 comments on commit 74ba4a0

Please sign in to comment.