Repository navigation
Unit test updates - #2
Conversation
| AreEqual(0, launch_ironpython_changing_extensions(__file__, remove=["-O"])) | ||
| else: | ||
| run_test(__name__) | ||
| # if is_cli and '-O' in System.Environment.GetCommandLineArgs(): |
There was a problem hiding this comment.
Could we retain this check in some form and make the test fail (or be skipped) if optimize is set? Maybe something like
@unittest.skipIf(sys.flags.optimize, "should be run without optimize")would work?
There was a problem hiding this comment.
It doesn't quite do what was originally there, but we could add the check for optimized.
| #my_name = os.environ.get(r'USERNAME', None) | ||
| #my_dir = my_name and path_combine(team_dir, my_name) or None | ||
| #my_profile = my_dir and path_combine(my_dir, r'settings.py') or None | ||
| # #team_dir = path_combine(ip_root, r'Team') |
There was a problem hiding this comment.
If this was already commented might as well just zap it.
There was a problem hiding this comment.
No, it's part of what makes this WIP still...I need it to refer back to as I work through test. It will be removed in the final commit.
| ##################################################################################### | ||
|
|
||
| AreEqual(z, 10) | ||
| self.assertEqual(z, 10) |
There was a problem hiding this comment.
I'm guessing more work needs to be done here?
There was a problem hiding this comment.
No, this is imported in test_execfile.py, it's just used for testing.
| from iptest.assert_util import * | ||
|
|
||
| Assert(__name__ in ["__main__", "test_execfile"], __name__) | ||
| self.assertTrue(__name__ in ["__main__", "test_execfile"], __name__) |
There was a problem hiding this comment.
Still working on this one?
There was a problem hiding this comment.
No, this is imported in test_execfile.py
| a = x() | ||
| try: | ||
| hasattr(a, 'abc') | ||
| AssertUnreachable() |
There was a problem hiding this comment.
Replace with unittest equivalent?
There was a problem hiding this comment.
Yes, when it works I don't see the errors for wrong assertion methods :-)
| import clr | ||
| cp946() | ||
| def test_no_clr_import(self): | ||
| self.cp946() |
There was a problem hiding this comment.
Does unittest guarantee that this one will run before the next one?
There was a problem hiding this comment.
No, but isn't the import local to the method?
There was a problem hiding this comment.
Yes the clr variable is local to the function, but just fact that we're importing clr causes some side effects (such as the C# methods becoming visible). For example:
def test():
import clr
assert "ToString" not in dir("a")
test()
assert "ToString" in dir("a")There was a problem hiding this comment.
I'll rename the methods, there is this note in the unittest docs:
"Note that the order in which the various test cases will be run is determined by sorting the test function names with respect to the built-in ordering for strings."
They will run in the correct order now, but I'll add a 00 an 01 respectively just to make sure.
There was a problem hiding this comment.
Maybe we could add something like assert not hasattr(object, "ToString") to check that clr isn't loaded?
|
|
||
| from iptest import IronPythonTestCase, is_cli | ||
|
|
||
| @unittest.skipUnless(is_cli, 'IronPython specific test case') |
There was a problem hiding this comment.
The skip was only on test_sanity. Although unless there's something cli specific in toexec.py it might not be necessary.
There was a problem hiding this comment.
You are right, I don't think it's needed at all.
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # | ||
| # This source code is subject to terms and conditions of the Apache License, Version 2.0. A | ||
| # This source code is subject to terms and conditions of the Apache License, Version 2.0. self.A |
| @@ -1,142 +0,0 @@ | |||
| ##################################################################################### | |||
There was a problem hiding this comment.
Where did this file one go?
There was a problem hiding this comment.
No tests were being run from this file and the framework for running the test no longer exists in the testing libraries.
| class D(C1): pass | ||
| d = D() | ||
| AreEqual([d.x, d.y], [100, 100]) | ||
| def test_delete_getattribute(self): |
There was a problem hiding this comment.
This one was disabled. Is it fixed now?
There was a problem hiding this comment.
Yes, it runs correctly. I generally have been enabling all the tests and then looking through to see if there really is something that should be disabled. I am also trying to use expectedFailure instead of disabling if there is an issue, that way it is noted in the logs.
| try: | ||
| hasattr(a, 'abc') | ||
| AssertUnreachable() | ||
| self.fail('Should not reach this point') |
There was a problem hiding this comment.
I think there is an assertUnreachable in IronPythonTestCase? There are probably more AssertUnreachable all over the place...
| import clr | ||
| cp946() | ||
| def test_no_clr_import(self): | ||
| self.cp946() |
There was a problem hiding this comment.
Maybe we could add something like assert not hasattr(object, "ToString") to check that clr isn't loaded?
| Fail("Returned value of getdebug method is not valid value:" + str(result)) | ||
|
|
||
|
|
||
| #CodePlex Work Item# 8202 |
There was a problem hiding this comment.
I believe this comment should go with test_000_get_debug.
| self.assertEqual(errno.errorcode[2], | ||
| "ENOENT") | ||
|
|
||
| @unittest.skipIf(is_posix, 'Test does not work on Mono') |
There was a problem hiding this comment.
Mono or posix? Do we have an is_mono?
| return "MyException is a user sub-type of IOError" | ||
|
|
||
| @skip("win32") | ||
| def test_clr_exception_has_non_trivial_exception_message(): |
There was a problem hiding this comment.
Did you move this one to another file?
| l[-1] = p2 | ||
| self.assertEqual(id(l[-1]), id(p2)) | ||
|
|
||
| @unittest.skipIf(is_netstandard or not is_cli, 'netstandard does not support PlatformNotSupportedException, nor does native') |
There was a problem hiding this comment.
The skipIf message should probably read something like: IronPython specific test, .NET Core throws a PlatformNotSupportedException
| self.assertTrue(is_complete) | ||
| self.assertEqual(Flag.Value, 32) | ||
|
|
||
| @unittest.skipIf(is_posix, "mono's GC behaves differently so we get another print when GC occurs") |
There was a problem hiding this comment.
in_mono instead of is_posix?
| def test_object(): | ||
| a = object() | ||
| b = object() | ||
| @unittest.skipUnless(is_cli, 'IronPython specific test case') |
There was a problem hiding this comment.
Move the skipUnless over to test_bool_nullablebool? test_object should work with CPython.
| except NameError: | ||
| pass | ||
|
|
||
| def test_file(): |
There was a problem hiding this comment.
Yes, it didn't seem to fit with the test of the tests.
| self.assertRaises(NameError, lambda: [(i, j) for i in range(10) if j < 'c' for j in ['a', 'b', 'c'] if i % 3 == 0]) | ||
|
|
||
| def test_negative_flow_checker(self): | ||
| self.assertRaises(NameError, lambda: [y for x in "python"]) |
There was a problem hiding this comment.
This seems like exactly the same as the test above?
There was a problem hiding this comment.
Yeah, I'll remove the second one.
|
|
||
| def test_stdin(self): | ||
| self.assertTrue('<stdin>' in str(sys.stdin)) | ||
| #self.assertTrue('<stdout>' in str(sys.stdout)) |
| AreEqual(id(x), id(True)) | ||
|
|
||
| def test_str_dict(): | ||
| print "CodePlex Work Item 13115" |
There was a problem hiding this comment.
Maybe preverse the codeplex # as a comment?
| if options.RUN_TESTS: #TODO - bug when generating Pydoc | ||
| from Merlin.Testing.FieldTest import * | ||
| from Merlin.Testing.TypeSample import * | ||
| class FieldMiscTest(IronPythonTestCase): |
There was a problem hiding this comment.
We probably want skipunless is_cli on all of these.
There was a problem hiding this comment.
I thought of that too, but wasn't sure we would ever try running these under CPython.
There was a problem hiding this comment.
I'm actually thinking about running the tests under CPython. Maybe not under CI, but it would be useful to highlight compatibility issues.
|
|
||
| def test_eval_dicts(self): | ||
| # eval referencing locals / globals | ||
| import System |
There was a problem hiding this comment.
Maybe move the import to the if is_cli block?
| self.assertRaises(TypeError, tuple.__new__, str) | ||
| self.assertRaises(TypeError, tuple.__new__, str, 'abc') | ||
|
|
||
| def test_override_pow(self): |
There was a problem hiding this comment.
Something wrong with this test?
| @@ -1,125 +0,0 @@ | |||
| ##################################################################################### | |||
There was a problem hiding this comment.
It was just calling the other loadorder tests, which will be run automatically now.
| AreEqual(NSwForwardee1.Foo.A, 120) | ||
| AreEqual(NSwForwardee1.Bar.A, -120) | ||
|
|
||
| @skip("multiple_execute", "posix") |
There was a problem hiding this comment.
In other places you kept the multiple_execute as a TODO however it seems you zapped it here.
|
|
||
| class BinasciiTest(unittest.TestCase): | ||
|
|
||
| @skipUnlessIronPython |
There was a problem hiding this comment.
I think we can remove the skipUnless, seems to work with CPython.
| @@ -1,944 +0,0 @@ | |||
| ##################################################################################### | |||
There was a problem hiding this comment.
It's renamed in a coming commit.
| t_in.close() | ||
|
|
||
| self.assertEqual(len(t_out_lines), 0) | ||
| print t_err_lines[0] |
There was a problem hiding this comment.
Are these prints for testing?
| try { | ||
| byte[] buffer = new byte[2048]; | ||
| MemoryStream result = new MemoryStream(n); | ||
| MemoryStream result = new MemoryStream(len); |
There was a problem hiding this comment.
Unrelated to the change, but wow, we're really allocating a 2gb array if len is not specified?
There was a problem hiding this comment.
Yes, that is indeed bad...
| "<type 'socket.ssl'>") | ||
|
|
||
| #--Negative | ||
| if is_cpython: |
There was a problem hiding this comment.
No, the file was renamed to match the test_*.py naming convention
There was a problem hiding this comment.
I meant the positive case of test_SSLType appears in test__ssl.py but I don't see the negative case...
There was a problem hiding this comment.
Ah, that's because there is no SSLType for the _ssl module anymore. Both IronPython and CPython get a message saying the module object has no attribute SSLType, so the test was bogus.
| s.connect((SSL_URL, SSL_PORT)) | ||
| ssl_s = real_ssl.sslwrap(s._sock, False) | ||
|
|
||
| if not is_cli: |
There was a problem hiding this comment.
Any reason why the shutdown is excluded here but not in other tests?
| f.bufsize = 4096 | ||
| self.assertEqual(4096, f.bufsize) | ||
|
|
||
| @unittest.skipIf(is_posix, 'some issue on mono, need to debug further') |
| nt.mkdir("dir_create_test") | ||
| try: | ||
| nt.mkdir("dir_create_test") | ||
| self.assertTrueUnreachabale("Cannot create the same directory twice") |
There was a problem hiding this comment.
replace all issue, will fix
|
|
||
| def test_negTestFunc_ObjectSubClass_testFunc_pw_kw_dupArg(self): | ||
| o = ObjectSubClass() | ||
| try: o.testFunc_pw_kw(a='abc') |
There was a problem hiding this comment.
Any idea why assertRaises doesn't work for these? Maybe add a comment that assertRaises should not be used here?
There was a problem hiding this comment.
I think it may have something to do with how the parameter is passed around (in the case of NOT using assertRaises, it is setting the value of the 'a' parameter, but when passed into assertRaises it is passed as **kwArgs. A comment is a good idea
There was a problem hiding this comment.
C Python doesn't seem to have any issues with it though, so I guess we have a bug.
Updates to IronPython specific unit tests to use the unittest