aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml4
-rw-r--r--asn1crypto/util.py10
-rw-r--r--dev/_import.py19
-rw-r--r--dev/coverage.py2
-rw-r--r--tests/test_core.py9
-rw-r--r--tox.ini2
6 files changed, 39 insertions, 7 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ab5738c..c6afaef 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -9,7 +9,7 @@ jobs:
matrix:
os:
- ubuntu-18.04
- - macOS-10.14
+ - macOS-latest
- windows-2019
python:
- '2.7'
@@ -20,7 +20,7 @@ jobs:
exclude:
- os: ubuntu-18.04
arch: x86
- - os: macOS-10.14
+ - os: macOS-latest
arch: x86
steps:
- uses: actions/checkout@master
diff --git a/asn1crypto/util.py b/asn1crypto/util.py
index 4d743df..7196897 100644
--- a/asn1crypto/util.py
+++ b/asn1crypto/util.py
@@ -161,6 +161,16 @@ if sys.version_info <= (3,):
return False
return self._offset == other._offset
+ def __getinitargs__(self):
+ """
+ Called by tzinfo.__reduce__ to support pickle and copy.
+
+ :return:
+ offset and name, to be used for __init__
+ """
+
+ return self._offset, self._name
+
def tzname(self, dt):
"""
:param dt:
diff --git a/dev/_import.py b/dev/_import.py
index 2599588..1041968 100644
--- a/dev/_import.py
+++ b/dev/_import.py
@@ -5,7 +5,12 @@ import imp
import sys
import os
-from . import build_root
+from . import build_root, package_name, package_root
+
+if sys.version_info < (3,):
+ getcwd = os.getcwdu
+else:
+ getcwd = os.getcwd
def _import_from(mod, path, mod_dir=None):
@@ -55,13 +60,18 @@ def _preload(require_oscrypto, print_info):
"""
if print_info:
+ print('Working dir: ' + getcwd())
print('Python ' + sys.version.replace('\n', ''))
asn1crypto = None
oscrypto = None
if require_oscrypto:
- oscrypto_dir = os.path.join(build_root, 'oscrypto')
+ # Some CI services don't use the package name for the dir
+ if package_name == 'oscrypto':
+ oscrypto_dir = package_root
+ else:
+ oscrypto_dir = os.path.join(build_root, 'oscrypto')
oscrypto_tests = None
if os.path.exists(oscrypto_dir):
oscrypto_tests = _import_from('oscrypto_tests', oscrypto_dir, 'tests')
@@ -70,7 +80,10 @@ def _preload(require_oscrypto, print_info):
asn1crypto, oscrypto = oscrypto_tests.local_oscrypto()
else:
- asn1crypto_dir = os.path.join(build_root, 'asn1crypto')
+ if package_name == 'asn1crypto':
+ asn1crypto_dir = package_root
+ else:
+ asn1crypto_dir = os.path.join(build_root, 'asn1crypto')
if os.path.exists(asn1crypto_dir):
asn1crypto = _import_from('asn1crypto', asn1crypto_dir)
if asn1crypto is None:
diff --git a/dev/coverage.py b/dev/coverage.py
index b9a55de..eb03b53 100644
--- a/dev/coverage.py
+++ b/dev/coverage.py
@@ -54,7 +54,7 @@ def run(ci=False):
cov.start()
from .tests import run as run_tests
- result = run_tests()
+ result = run_tests(ci=ci)
print()
if ci:
diff --git a/tests/test_core.py b/tests/test_core.py
index aaff9f5..41ea71d 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -409,6 +409,15 @@ class CoreTests(unittest.TestCase):
# Is past 2050
core.UTCTime(datetime(2106, 2, 7, 6, 28, 16, tzinfo=util.timezone.utc))
+ def test_utctime_copy(self):
+ a = core.UTCTime(datetime(2019, 11, 11, 17, 45, 18, tzinfo=util.timezone.utc))
+ # Ensure _native is set because we want to test copy on the nested timezone object.
+ a.native
+ b = a.copy()
+ self.assertEqual(a.native, b.native)
+ self.assertEqual(a.contents, b.contents)
+ self.assertEqual(a.dump(), b.dump())
+
@staticmethod
def generalized_time_info():
def tz(hours, minutes=0):
diff --git a/tox.ini b/tox.ini
index 1f2e7e4..dbf71ee 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py26,py27,py32,py33,py34,py35,py36,py37,pypy
+envlist = py26,py27,py32,py33,py34,py35,py36,py37,py38,pypy
[testenv]
deps = -rrequires/ci