Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ensure that sys.argv is set#301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vmuriart merged 2 commits intomasterfromsetsysargv
Feb 8, 2017
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletionssrc/embed_tests/pyimport.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
using System;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using Python.Runtime;
using System.IO;

namespace Python.EmbeddingTest
{
Expand DownExpand Up@@ -55,5 +53,15 @@ public void TestDottedName()
PyObject module = PythonEngine.ImportModule("PyImportTest.test.one");
Assert.IsNotNull(module, ">>> import PyImportTest.test.one # FAILED");
}

/// <summary>
/// Tests that sys.args is set. If it wasn't exception would be raised.
/// </summary>
[Test]
public void TestSysArgsImportException()
{
PyObject module = PythonEngine.ImportModule("PyImportTest.sysargv");
Assert.IsNotNull(module, ">>> import PyImportTest.sysargv # FAILED");
}
}
}
5 changes: 5 additions & 0 deletionssrc/tests/PyImportTest/sysargv.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-

import sys
# if argv is available, as expected, then no exception
num_args = len(sys.argv)
3 changes: 3 additions & 0 deletionssrc/tests/runtests.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,9 @@
clr.AddReference("System.Management")

test_modules = (
# has to be first test before other module import clr
'test_sysargv',

# test_module passes on its own, but not here if
# other test modules that import System.Windows.Forms
# run first. They must not do module level import/AddReference()
Expand Down
17 changes: 17 additions & 0 deletionssrc/tests/test_sysargv.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-

import unittest
import sys

class SysArgvTests(unittest.TestCase):
"""Test sys.argv state."""

def test_sys_argv_state(self):
"""Test sys.argv state doesn't change after clr import."""
argv = sys.argv
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should be argv = list(sys.argv) - need to make a copy

import clr
self.assertTrue(argv == sys.argv)


def test_suite():
return unittest.makeSuite(SysArgvTests)
2 changes: 2 additions & 0 deletionssrc/tests/tests.pyproj
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,12 +29,14 @@
<ItemGroup>
<Compile Include="leaktest.py" />
<Compile Include="profile.py" />
<Compile Include="PyImportTest\sysargv.py" />
<Compile Include="PyImportTest\test\one.py" />
<Compile Include="PyImportTest\test\__init__.py" />
<Compile Include="PyImportTest\__init__.py" />
<Compile Include="runtests.py" />
<Compile Include="stress.py" />
<Compile Include="stresstest.py" />
<Compile Include="test_sysargv.py" />
<Compile Include="test_array.py" />
<Compile Include="test_class.py" />
<Compile Include="test_compat.py" />
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp