test_compat.py 763 B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. # Copyright (c) 2021, Brandon Nielsen
  3. # All rights reserved.
  4. #
  5. # This software may be modified and distributed under the terms
  6. # of the BSD license. See the LICENSE file for details.
  7. import unittest
  8. from aniso8601.compat import PY2, is_string
  9. class TestCompatFunctions(unittest.TestCase):
  10. def test_is_string(self):
  11. self.assertTrue(is_string("asdf"))
  12. self.assertTrue(is_string(""))
  13. # pylint: disable=undefined-variable
  14. if PY2 is True:
  15. self.assertTrue(is_string(unicode("asdf")))
  16. self.assertFalse(is_string(None))
  17. self.assertFalse(is_string(123))
  18. self.assertFalse(is_string(4.56))
  19. self.assertFalse(is_string([]))
  20. self.assertFalse(is_string({}))