Created
December 9, 2014 18:00
-
-
Save ironpythonbot/0424373fe13d35a74bbe to your computer and use it in GitHub Desktop.
CodePlex Issue #32465 Plain Text Attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Check up on IronPython work items. | |
Use: | |
ipy -m unittest testipy [or other fully qualified test names] | |
ipy -m testipy [optional test names relative to this module] | |
""" | |
import copy | |
from datetime import date, time | |
import unittest | |
from System import InvalidOperationException | |
class IronPythonTestCase(unittest.TestCase): | |
def test_assertRaises(self): | |
"""http://ironpython.codeplex.com/workitem/30119""" | |
with self.assertRaises(InvalidOperationException): | |
raise InvalidOperationException('assertRaises should catch this') | |
def test_copy_time(self): | |
"""http://ironpython.codeplex.com/workitem/30274""" | |
t = time(9) | |
self.assertEqual(t, copy.deepcopy(t)) | |
def test_set_update(self): | |
"""http://ironpython.codeplex.com/workitem/30386""" | |
y = set() | |
y |= {'a'} | |
y |= {'a', 'b'} | |
z = set() | |
z |= y | |
z |= y | |
def test_union(self): | |
"""http://ironpython.codeplex.com/workitem/30153""" | |
a = {'x'} | |
b = a | a | |
c = b | b | |
def test_date_format(self): | |
"""http://ironpython.codeplex.com/workitem/30447""" | |
words = 'On Wednesdays I go shopping and have buttered sconds for tea.' | |
template = 'On {when:%A}s I go shopping and have {food} for tea.' | |
result = template.format(food='buttered sconds', when=date(2011, 10, 5)) | |
self.assertEqual(words, result) | |
def test_generator_scope(self): | |
"""Test the scopes of the variables in a nested generator. | |
CPython 2.7.2 passes. | |
IronPython 2.7.2.1 raises an exception: | |
NameError: global name 'row' is not defined | |
""" | |
metadata = [{'column_name': 'splunge', 'data_type': 'varchar(128)'}] | |
patterns = ['lunge'] | |
columns = {row['column_name']: row['data_type'].lower() | |
for row in metadata | |
if patterns is None or | |
any(p.lower() in row['column_name'].lower() | |
for p in patterns)} | |
self.assertEqual({'splunge': 'varchar(128)'}, columns) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment