diff options
author | Brett Cannon <brett@python.org> | 2012-02-16 23:03:47 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-02-16 23:03:47 (GMT) |
commit | 22e7c88057ee91ded2bd9853a6b67846c34d392f (patch) | |
tree | 3241f635caa35ea9bd18bd5f1617e3e6b705efe7 /Lib | |
parent | 3b1a06c1eaec92242683b0a3460377e03cb6c214 (diff) | |
parent | 1639505c383a1c8b46ff6f2a5b9071f26ad43ece (diff) | |
download | cpython-22e7c88057ee91ded2bd9853a6b67846c34d392f.zip cpython-22e7c88057ee91ded2bd9853a6b67846c34d392f.tar.gz cpython-22e7c88057ee91ded2bd9853a6b67846c34d392f.tar.bz2 |
Merge
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_sched.py | 28 | ||||
-rw-r--r-- | Lib/test/test_xml_etree.py | 8 | ||||
-rw-r--r-- | Lib/test/test_xml_etree_c.py | 5 | ||||
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 2 |
4 files changed, 22 insertions, 21 deletions
diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py index ae82f94..50ada52 100644 --- a/Lib/test/test_sched.py +++ b/Lib/test/test_sched.py @@ -12,10 +12,10 @@ class TestCase(unittest.TestCase): l = [] fun = lambda x: l.append(x) scheduler = sched.scheduler(time.time, time.sleep) - for x in [0.05, 0.04, 0.03, 0.02, 0.01]: + for x in [0.5, 0.4, 0.3, 0.2, 0.1]: z = scheduler.enter(x, 1, fun, (x,)) scheduler.run() - self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05]) + self.assertEqual(l, [0.1, 0.2, 0.3, 0.4, 0.5]) def test_enterabs(self): l = [] @@ -31,7 +31,7 @@ class TestCase(unittest.TestCase): fun = lambda x: l.append(x) scheduler = sched.scheduler(time.time, time.sleep) for priority in [1, 2, 3, 4, 5]: - z = scheduler.enter(0.01, priority, fun, (priority,)) + z = scheduler.enterabs(0.01, priority, fun, (priority,)) scheduler.run() self.assertEqual(l, [1, 2, 3, 4, 5]) @@ -39,11 +39,12 @@ class TestCase(unittest.TestCase): l = [] fun = lambda x: l.append(x) scheduler = sched.scheduler(time.time, time.sleep) - event1 = scheduler.enter(0.01, 1, fun, (0.01,)) - event2 = scheduler.enter(0.02, 1, fun, (0.02,)) - event3 = scheduler.enter(0.03, 1, fun, (0.03,)) - event4 = scheduler.enter(0.04, 1, fun, (0.04,)) - event5 = scheduler.enter(0.05, 1, fun, (0.05,)) + now = time.time() + event1 = scheduler.enterabs(now + 0.01, 1, fun, (0.01,)) + event2 = scheduler.enterabs(now + 0.02, 1, fun, (0.02,)) + event3 = scheduler.enterabs(now + 0.03, 1, fun, (0.03,)) + event4 = scheduler.enterabs(now + 0.04, 1, fun, (0.04,)) + event5 = scheduler.enterabs(now + 0.05, 1, fun, (0.05,)) scheduler.cancel(event1) scheduler.cancel(event5) scheduler.run() @@ -64,11 +65,12 @@ class TestCase(unittest.TestCase): l = [] fun = lambda x: l.append(x) scheduler = sched.scheduler(time.time, time.sleep) - e5 = scheduler.enter(0.05, 1, fun) - e1 = scheduler.enter(0.01, 1, fun) - e2 = scheduler.enter(0.02, 1, fun) - e4 = scheduler.enter(0.04, 1, fun) - e3 = scheduler.enter(0.03, 1, fun) + now = time.time() + e5 = scheduler.enterabs(now + 0.05, 1, fun) + e1 = scheduler.enterabs(now + 0.01, 1, fun) + e2 = scheduler.enterabs(now + 0.02, 1, fun) + e4 = scheduler.enterabs(now + 0.04, 1, fun) + e3 = scheduler.enterabs(now + 0.03, 1, fun) # queue property is supposed to return an order list of # upcoming events self.assertEqual(list(scheduler.queue), [e1, e2, e3, e4, e5]) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 6060e06..58fdcd4 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1352,7 +1352,6 @@ def xinclude(): r""" Basic inclusion example (XInclude C.1) - >>> from xml.etree import ElementTree as ET >>> from xml.etree import ElementInclude >>> document = xinclude_loader("C1.xml") @@ -1882,12 +1881,7 @@ class CleanContext(object): def __enter__(self): from xml.etree import ElementPath - if hasattr(ET, '_namespace_map'): - self._nsmap = ET._namespace_map - else: - # when testing the cElementTree alias - from xml.etree.ElementTree import _namespace_map - self._nsmap = _namespace_map + self._nsmap = ET.register_namespace._namespace_map # Copy the default namespace mapping self._nsmap_copy = self._nsmap.copy() # Copy the path cache (should be empty) diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py index dbe1c3a..a73d0c4 100644 --- a/Lib/test/test_xml_etree_c.py +++ b/Lib/test/test_xml_etree_c.py @@ -5,7 +5,7 @@ from test.support import import_fresh_module import unittest cET = import_fresh_module('xml.etree.ElementTree', fresh=['_elementtree']) -cET_alias = import_fresh_module('xml.etree.cElementTree', fresh=['_elementtree']) +cET_alias = import_fresh_module('xml.etree.cElementTree', fresh=['_elementtree', 'xml.etree']) # cElementTree specific tests @@ -52,6 +52,9 @@ class TestAcceleratorImported(unittest.TestCase): def test_correct_import_cET(self): self.assertEqual(cET.Element.__module__, '_elementtree') + def test_correct_import_cET_alias(self): + self.assertEqual(cET_alias.Element.__module__, '_elementtree') + def test_main(): from test import test_xml_etree, test_xml_etree_c diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index 93147eb..defef0d 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -1086,6 +1086,8 @@ _namespace_map = { # dublin core "http://purl.org/dc/elements/1.1/": "dc", } +# For tests and troubleshooting +register_namespace._namespace_map = _namespace_map def _raise_serialization_error(text): raise TypeError( |