|
1 | 1 | import os
|
2 |
| -import time |
3 | 2 | import unittest
|
4 |
| -from os.path import expanduser |
5 | 3 |
|
| 4 | +import time |
6 | 5 | from nose.tools import timed
|
7 | 6 |
|
8 | 7 | from core.settings import Settings
|
|
13 | 12 |
|
14 | 13 | # noinspection PyMethodMayBeStatic
|
15 | 14 | class RunTests(unittest.TestCase):
|
| 15 | + current_folder = os.path.dirname(os.path.realpath(__file__)) |
16 | 16 |
|
17 | 17 | def tearDown(self):
|
18 | 18 | Process.kill_all_in_context()
|
19 | 19 |
|
20 | 20 | def test_01_run_simple_command(self):
|
21 |
| - home = expanduser("~") |
22 |
| - result = run(cmd='ls ' + home, wait=True, timeout=1) |
| 21 | + result = run(cmd='ls ' + self.current_folder, wait=True, timeout=1) |
23 | 22 | assert result.exit_code == 0, 'Wrong exit code of successful command.'
|
24 | 23 | assert result.log_file is None, 'No log file should be generated if wait=True.'
|
25 | 24 | assert result.complete is True, 'Complete should be true when process execution is complete.'
|
26 | 25 | assert result.duration < 1, 'Process duration took too much time.'
|
27 |
| - assert 'Desktop' in result.output, 'Listing home do not include Desktop folder.' |
| 26 | + assert 'run_tests.py' in result.output, 'Listing do not return correct output.' |
28 | 27 |
|
29 | 28 | def test_02_run_command_with_redirect(self):
|
30 |
| - home = expanduser("~") |
31 | 29 | out_file = os.path.join(Settings.TEST_OUT_HOME, 'log.txt')
|
32 |
| - result = run(cmd='ls ' + home + ' > ' + out_file, wait=True, timeout=1) |
| 30 | + result = run(cmd='ls ' + self.current_folder + ' > ' + out_file, wait=True, timeout=1) |
33 | 31 | assert result.exit_code == 0, 'Wrong exit code of successful command.'
|
34 | 32 | assert result.log_file is None, 'No log file should be generated if wait=True.'
|
35 | 33 | assert result.complete is True, 'Complete should be true when process execution is complete.'
|
36 | 34 | assert result.duration < 1, 'Process duration took too much time.'
|
37 | 35 | assert result.output == '', 'Output should be empty.'
|
38 |
| - assert 'Desktop' in File.read(path=out_file) |
| 36 | + assert 'run_tests.py' in File.read(path=out_file) |
39 | 37 |
|
40 | 38 | def test_03_run_command_with_pipe(self):
|
41 | 39 | result = run(cmd='echo "test case" | wc -w ', wait=True, timeout=1)
|
|
0 commit comments