forked from projectmesa/mesa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_main.py
28 lines (22 loc) · 846 Bytes
/
test_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import sys
import unittest
from unittest.mock import patch
from click.testing import CliRunner
from mesa.main import cli
class TestCli(unittest.TestCase):
'''
Test CLI commands
'''
def setUp(self):
self.old_sys_path = sys.path[:]
self.runner = CliRunner()
def tearDown(self):
sys.path[:] = self.old_sys_path
def test_run(self):
with patch('mesa.visualization.ModularVisualization.ModularServer') as ModularServer:
example_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../examples/wolf_sheep'))
with self.runner.isolated_filesystem():
result = self.runner.invoke(cli, ['runserver', example_dir])
assert result.exit_code == 0, result.output
assert ModularServer().launch.call_count == 1