Author: Brian Kearns <[email protected]>
Branch: cleanup-tests
Changeset: r60887:d57434b6a9d7
Date: 2013-02-05 17:52 -0500
http://bitbucket.org/pypy/pypy/changeset/d57434b6a9d7/
Log: merge tests in the two datetime test files
diff --git a/pypy/module/test_lib_pypy/test_datetime.py
b/pypy/module/test_lib_pypy/test_datetime.py
--- a/pypy/module/test_lib_pypy/test_datetime.py
+++ b/pypy/module/test_lib_pypy/test_datetime.py
@@ -57,3 +57,50 @@
for t in sorted(expected_results):
dt = datetime.datetime.utcfromtimestamp(t)
assert repr(dt) == expected_results[t]
+
+def test_utcfromtimestamp():
+ """Confirm that utcfromtimestamp and fromtimestamp give consistent results.
+
+ Based on danchr's test script in https://bugs.pypy.org/issue986
+ """
+ import os
+ import time
+ try:
+ prev_tz = os.environ.get("TZ")
+ os.environ["TZ"] = "GMT"
+ for unused in xrange(100):
+ now = time.time()
+ delta = (datetime.datetime.utcfromtimestamp(now) -
+ datetime.datetime.fromtimestamp(now))
+ assert delta.days * 86400 + delta.seconds == 0
+ finally:
+ if prev_tz is None:
+ del os.environ["TZ"]
+ else:
+ os.environ["TZ"] = prev_tz
+
+def test_utcfromtimestamp_microsecond():
+ dt = datetime.datetime.utcfromtimestamp(0)
+ assert isinstance(dt.microsecond, int)
+
+def test_integer_args():
+ with py.test.raises(TypeError):
+ datetime.datetime(10, 10, 10.)
+ with py.test.raises(TypeError):
+ datetime.datetime(10, 10, 10, 10, 10.)
+ with py.test.raises(TypeError):
+ datetime.datetime(10, 10, 10, 10, 10, 10.)
+
+def test_utcnow_microsecond():
+ import copy
+
+ dt = datetime.datetime.utcnow()
+ assert type(dt.microsecond) is int
+
+ copy.copy(dt)
+
+def test_radd():
+ class X(object):
+ def __radd__(self, other):
+ return "radd"
+ assert datetime.date(10, 10, 10) + X() == "radd"
diff --git a/pypy/module/test_lib_pypy/test_datetime_extra.py
b/pypy/module/test_lib_pypy/test_datetime_extra.py
deleted file mode 100644
--- a/pypy/module/test_lib_pypy/test_datetime_extra.py
+++ /dev/null
@@ -1,52 +0,0 @@
-"""Additional tests for datetime."""
-
-import py
-
-import time
-from lib_pypy import datetime
-import copy
-import os
-
-def test_utcfromtimestamp():
- """Confirm that utcfromtimestamp and fromtimestamp give consistent results.
-
- Based on danchr's test script in https://bugs.pypy.org/issue986
- """
- try:
- prev_tz = os.environ.get("TZ")
- os.environ["TZ"] = "GMT"
- for unused in xrange(100):
- now = time.time()
- delta = (datetime.datetime.utcfromtimestamp(now) -
- datetime.datetime.fromtimestamp(now))
- assert delta.days * 86400 + delta.seconds == 0
- finally:
- if prev_tz is None:
- del os.environ["TZ"]
- else:
- os.environ["TZ"] = prev_tz
-
-def test_utcfromtimestamp_microsecond():
- dt = datetime.datetime.utcfromtimestamp(0)
- assert isinstance(dt.microsecond, int)
-
-
-def test_integer_args():
- with py.test.raises(TypeError):
- datetime.datetime(10, 10, 10.)
- with py.test.raises(TypeError):
- datetime.datetime(10, 10, 10, 10, 10.)
- with py.test.raises(TypeError):
- datetime.datetime(10, 10, 10, 10, 10, 10.)
-
-def test_utcnow_microsecond():
- dt = datetime.datetime.utcnow()
- assert type(dt.microsecond) is int
-
- copy.copy(dt)
-
-def test_radd():
- class X(object):
- def __radd__(self, other):
- return "radd"
- assert datetime.date(10, 10, 10) + X() == "radd"
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit