Skip to content

Commit 9853f7e

Browse files
committed
fix: unit tests
1 parent 7b35cde commit 9853f7e

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
language: python
22
python:
33
- "2.7"
4+
node_js: 10
5+
before_install:
6+
- pip install -U pip
47
install:
5-
- sudo apt-get install tesseract-ocr-eng
8+
- ls ~/
9+
- sudo apt install tesseract-ocr
10+
- sudo apt install libtesseract-dev
611
- python -m pip install --upgrade pip
712
- pip install --upgrade -r requirements.txt
813
script:

core_tests/utils/process_tests.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1-
import time
21
import unittest
32

3+
import time
4+
5+
from core.enums.os_type import OSType
6+
from core.settings import Settings
47
from core.utils.process import Process
58
from core.utils.run import run
69

710

811
class ProcessTests(unittest.TestCase):
12+
if Settings.HOST_OS == OSType.WINDOWS:
13+
http_module = 'http.server'
14+
else:
15+
http_module = 'SimpleHTTPServer'
916

1017
def test_30_kill_by_port(self):
1118
port = 4210
1219
self.start_server(port=port)
1320
time.sleep(0.5)
14-
running = Process.is_running_by_commandline(commandline='http.server')
21+
running = Process.is_running_by_commandline(commandline=self.http_module)
1522
assert running, 'Failed to start simple http server.'
1623
Process.kill_by_port(port=port)
1724
time.sleep(0.5)
18-
running = Process.is_running_by_commandline(commandline='http.server')
25+
running = Process.is_running_by_commandline(commandline=self.http_module)
1926
assert not running, 'Kill by port failed to kill process.'
2027

21-
@staticmethod
22-
def start_server(port):
23-
run(cmd='python -m http.server ' + str(port), wait=False)
28+
def start_server(self, port):
29+
run(cmd='python -m {0} {1}'.format(self.http_module, str(port)), wait=False)
2430

2531

2632
if __name__ == '__main__':

0 commit comments

Comments
 (0)