This repository was archived by the owner on Jul 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +38
-3
lines changed
Expand file tree Collapse file tree 5 files changed +38
-3
lines changed Original file line number Diff line number Diff line change 11using System ;
2- using System . Reflection ;
3- using System . Collections . Generic ;
2+ using System . IO ;
43using NUnit . Framework ;
54using Python . Runtime ;
6- using System . IO ;
75
86namespace Python . EmbeddingTest
97{
@@ -55,5 +53,15 @@ public void TestDottedName()
5553 PyObject module = PythonEngine . ImportModule ( "PyImportTest.test.one" ) ;
5654 Assert . IsNotNull ( module , ">>> import PyImportTest.test.one # FAILED" ) ;
5755 }
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+ }
5866 }
5967}
Original file line number Diff line number Diff line change 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 2323 clr .AddReference ("System.Management" )
2424
2525test_modules = (
26+ # has to be first test before other module import clr
27+ 'test_sysargv' ,
28+
2629 # test_module passes on its own, but not here if
2730 # other test modules that import System.Windows.Forms
2831 # run first. They must not do module level import/AddReference()
Original file line number Diff line number Diff line change 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 2929 <ItemGroup >
3030 <Compile Include =" leaktest.py" />
3131 <Compile Include =" profile.py" />
32+ <Compile Include =" PyImportTest\sysargv.py" />
3233 <Compile Include =" PyImportTest\test\one.py" />
3334 <Compile Include =" PyImportTest\test\__init__.py" />
3435 <Compile Include =" PyImportTest\__init__.py" />
3536 <Compile Include =" runtests.py" />
3637 <Compile Include =" stress.py" />
3738 <Compile Include =" stresstest.py" />
39+ <Compile Include =" test_sysargv.py" />
3840 <Compile Include =" test_array.py" />
3941 <Compile Include =" test_class.py" />
4042 <Compile Include =" test_compat.py" />
You can’t perform that action at this time.
0 commit comments