| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8afd512 commit 79eeb61
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,7 @@ | |||
| 1 | 1 | using System; | |
| 2 | - using System.Reflection; | ||
| 3 | - using System.Collections.Generic; | ||
| 2 | + using System.IO; | ||
| 4 | 3 | using NUnit.Framework; | |
| 5 | 4 | using Python.Runtime; | |
| 6 | - using System.IO; | ||
| 7 | 5 | ||
| 8 | 6 | namespace Python.EmbeddingTest | |
| 9 | 7 | { | |
@@ -55,5 +53,15 @@ public void TestDottedName() | |||
| 55 | 53 | PyObject module = PythonEngine.ImportModule("PyImportTest.test.one"); | |
| 56 | 54 | Assert.IsNotNull(module, ">>> import PyImportTest.test.one # FAILED"); | |
| 57 | 55 | } | |
| 56 | + | ||
| 57 | + /// <summary> | ||
| 58 | + /// Tests that sys.args is set. If it wasn't exception would be raised. | ||
| 59 | + /// </summary> | ||
| 60 | + [Test] | ||
| 61 | + public void TestSysArgsImportException() | ||
| 62 | + { | ||
| 63 | + PyObject module = PythonEngine.ImportModule("PyImportTest.sysargv"); | ||
| 64 | + Assert.IsNotNull(module, ">>> import PyImportTest.sysargv # FAILED"); | ||
| 65 | + } | ||
| 58 | 66 | } | |
| 59 | 67 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,5 @@ | |||
| 1 | + # -*- coding: utf-8 -*- | ||
| 2 | + | ||
| 3 | + import sys | ||
| 4 | + # if argv is available, as expected, then no exception | ||
| 5 | + num_args = len(sys.argv) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,9 @@ | |||
| 23 | 23 | clr.AddReference("System.Management") | |
| 24 | 24 | ||
| 25 | 25 | test_modules = ( | |
| 26 | + # has to be first test before other module import clr | ||
| 27 | + 'test_sysargv', | ||
| 28 | + | ||
| 26 | 29 | # test_module passes on its own, but not here if | |
| 27 | 30 | # other test modules that import System.Windows.Forms | |
| 28 | 31 | # run first. They must not do module level import/AddReference() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,17 @@ | |||
| 1 | + # -*- coding: utf-8 -*- | ||
| 2 | + | ||
| 3 | + import unittest | ||
| 4 | + import sys | ||
| 5 | + | ||
| 6 | + class SysArgvTests(unittest.TestCase): | ||
| 7 | + """Test sys.argv state.""" | ||
| 8 | + | ||
| 9 | + def test_sys_argv_state(self): | ||
| 10 | + """Test sys.argv state doesn't change after clr import.""" | ||
| 11 | + argv = sys.argv | ||
| 12 | + import clr | ||
| 13 | + self.assertTrue(argv == sys.argv) | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + def test_suite(): | ||
| 17 | + return unittest.makeSuite(SysArgvTests) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,12 +29,14 @@ | |||
| 29 | 29 | <ItemGroup> | |
| 30 | 30 | <Compile Include="leaktest.py" /> | |
| 31 | 31 | <Compile Include="profile.py" /> | |
| 32 | + <Compile Include="PyImportTest\sysargv.py" /> | ||
| 32 | 33 | <Compile Include="PyImportTest\test\one.py" /> | |
| 33 | 34 | <Compile Include="PyImportTest\test\__init__.py" /> | |
| 34 | 35 | <Compile Include="PyImportTest\__init__.py" /> | |
| 35 | 36 | <Compile Include="runtests.py" /> | |
| 36 | 37 | <Compile Include="stress.py" /> | |
| 37 | 38 | <Compile Include="stresstest.py" /> | |
| 39 | + <Compile Include="test_sysargv.py" /> | ||
| 38 | 40 | <Compile Include="test_array.py" /> | |
| 39 | 41 | <Compile Include="test_class.py" /> | |
| 40 | 42 | <Compile Include="test_compat.py" /> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments