-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use another way to process args; write tests
- Loading branch information
1 parent
ee0bdc3
commit a3fa96f
Showing
5 changed files
with
89 additions
and
26 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import subprocess | ||
import unittest | ||
import os | ||
import tempfile | ||
import shutil | ||
import sys | ||
|
||
|
||
class TestGeneral(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.original_directory = os.getcwd() | ||
self.temp_directory = tempfile.mkdtemp() | ||
os.chdir(self.temp_directory) | ||
|
||
def tearDown(self): | ||
os.chdir(self.original_directory) | ||
try: | ||
shutil.rmtree(self.temp_directory) | ||
except: | ||
pass | ||
|
||
def test_randseed_arg(self): | ||
with open("test_randseed.py", 'w', encoding='utf-8') as f: | ||
f.write("import cyaron as c\n" | ||
"c.process_args()\n" | ||
"for i in range(10):\n" | ||
" print(c.randint(1,1000000000),end=' ')\n") | ||
|
||
env = os.environ.copy() | ||
env['PYTHONPATH'] = self.original_directory + os.pathsep + env.get( | ||
'PYTHONPATH', '') | ||
result = subprocess.run([ | ||
sys.executable, 'test_randseed.py', | ||
'--randseed=pinkrabbit147154220' | ||
], | ||
env=env, | ||
stdout=subprocess.PIPE, | ||
universal_newlines=True, | ||
check=True) | ||
self.assertEqual( | ||
result.stdout, | ||
"243842479 490459912 810766286 646030451 191412261 929378523 273000814 982402032 436668773 957169453 " | ||
) |
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
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