summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Ganssle <paul@ganssle.io>2019-11-02 14:38:44 -0400
committerGitHub <noreply@github.com>2019-11-02 14:38:44 -0400
commite31bd875e1da009e60e49432abd566d13a6fec5a (patch)
tree9aba2caccc5bbd4095d2d101f18395f29def9a80
parentc31392f853819b8e5db0d032f6d79aadb4100a2b (diff)
parentf9fbb340daa4e4c6d0f26786e1b7fb044ad3dc3a (diff)
downloaddateutil-git-e31bd875e1da009e60e49432abd566d13a6fec5a.tar.gz
Merge pull request #893 from shadchin/fix_tests
Fix tests if not TZ change allowed
-rw-r--r--AUTHORS.md1
-rw-r--r--changelog.d/893.misc.rst2
-rw-r--r--dateutil/test/_common.py8
-rw-r--r--dateutil/test/test_tz.py8
4 files changed, 10 insertions, 9 deletions
diff --git a/AUTHORS.md b/AUTHORS.md
index bf8428f..b5ae484 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -19,6 +19,7 @@ switch, and thus all their contributions are dual-licensed.
- Alex Verdyan <verdyan@MASKED>
- Alex Willmer <alex@moreati.org.uk> (gh: @moreati) **R**
- Alexander Brugh <alexander.brugh@MASKED> (gh: @abrugh)
+- Alexander Shadchin <alexandr.shadchin@gmail.com> (gh: @shadchin) **D**
- Alistair McMaster <alistair@MASKED> (gh: @alimcmaster1 ) **D**
- Allison Quinlan <aquinlan82@gmail.com> (gh: @aquinlan) **D**
- Andrew Bennett (gh: @andrewcbennett) **D**
diff --git a/changelog.d/893.misc.rst b/changelog.d/893.misc.rst
new file mode 100644
index 0000000..fed687e
--- /dev/null
+++ b/changelog.d/893.misc.rst
@@ -0,0 +1,2 @@
+Fix tests if TZ not change allowed.
+Patch by @shadchin (gh pr #893)
diff --git a/dateutil/test/_common.py b/dateutil/test/_common.py
index e46dc4b..b8d2047 100644
--- a/dateutil/test/_common.py
+++ b/dateutil/test/_common.py
@@ -6,6 +6,8 @@ import warnings
import tempfile
import pickle
+import pytest
+
class PicklableMixin(object):
def _get_nobj_bytes(self, obj, dump_kwargs, load_kwargs):
@@ -85,7 +87,11 @@ class TZContextBase(object):
def __enter__(self):
if not self.tz_change_allowed():
- raise ValueError(self.tz_change_disallowed_message())
+ msg = self.tz_change_disallowed_message()
+ pytest.skip(msg)
+
+ # If this is used outside of a test suite, we still want an error.
+ raise ValueError(msg) # pragma: no cover
self._old_tz = self.get_current_tz()
self.set_current_tz(self.tzval)
diff --git a/dateutil/test/test_tz.py b/dateutil/test/test_tz.py
index 4180199..d628826 100644
--- a/dateutil/test/test_tz.py
+++ b/dateutil/test/test_tz.py
@@ -851,8 +851,6 @@ def test_tzoffset_is_not():
@pytest.mark.tzlocal
@unittest.skipIf(IS_WIN, "requires Unix")
-@unittest.skipUnless(TZEnvContext.tz_change_allowed(),
- TZEnvContext.tz_change_disallowed_message())
class TzLocalNixTest(unittest.TestCase, TzFoldMixin):
# This is a set of tests for `tzlocal()` on *nix systems
@@ -962,8 +960,6 @@ def mark_tzlocal_nix(f):
marks = [
pytest.mark.tzlocal,
pytest.mark.skipif(IS_WIN, reason='requires Unix'),
- pytest.mark.skipif(not TZEnvContext.tz_change_allowed,
- reason=TZEnvContext.tz_change_disallowed_message())
]
for mark in reversed(marks):
@@ -2070,8 +2066,6 @@ class TZTest(unittest.TestCase):
datetime(2007, 8, 6, 2, 10, tzinfo=tz.tzstr("UTC-2")))
@unittest.skipIf(IS_WIN, "requires Unix")
- @unittest.skipUnless(TZEnvContext.tz_change_allowed(),
- TZEnvContext.tz_change_disallowed_message())
def testTZSetDoesntCorrupt(self):
# if we start in non-UTC then tzset UTC make sure parse doesn't get
# confused
@@ -2254,8 +2248,6 @@ class TzWinTest(unittest.TestCase, TzWinFoldMixin):
@unittest.skipUnless(IS_WIN, "Requires Windows")
-@unittest.skipUnless(TZWinContext.tz_change_allowed(),
- TZWinContext.tz_change_disallowed_message())
class TzWinLocalTest(unittest.TestCase, TzWinFoldMixin):
def setUp(self):