Skip to content

Commit

Permalink
fix: test case fail
Browse files Browse the repository at this point in the history
  • Loading branch information
manhinhang committed Apr 20, 2024
1 parent 81837ba commit 5478217
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions test/test_ib_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

IMAGE_NAME = os.environ['IMAGE_NAME']

# scope='session' uses the same container for all the tests;
# scope='function' uses a new container per test function.
@pytest.fixture(scope='function')
def host(request):
def test_healthcheck(host):
account = os.environ['IB_ACCOUNT']
password = os.environ['IB_PASSWORD']
trading_mode = os.environ['TRADING_MODE']
Expand All @@ -20,15 +17,5 @@ def host(request):
'--env', 'IB_PASSWORD={}'.format(password),
'--env', 'TRADING_MODE={}'.format(trading_mode),
'-d', IMAGE_NAME]).decode().strip()

# at the end of the test suite, destroy the container
def remove_container():
subprocess.check_call(['docker', 'rm', '-f', docker_id])
request.addfinalizer(remove_container)

# return a testinfra connection to the container
yield testinfra.get_host("docker://" + docker_id)

def test_heathcheck(host):
assert host.exists("healthcheck")
assert host.run('healthcheck').rc == 0
assert subprocess.check_call(['docker', 'exec', docker_id, 'healthcheck']) == 0
subprocess.check_call(['docker', 'rm', '-f', docker_id])

0 comments on commit 5478217

Please sign in to comment.