-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make tests pass #446
Make tests pass #446
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import os | ||
import re | ||
from unittest import mock | ||
|
||
import pytest | ||
|
@@ -91,12 +92,12 @@ def test_cli_with_progress(docker_client_mock, project_dir, test_mock): | |
result = runner.invoke(cli, ["dev"]) | ||
assert result.exit_code == 0 | ||
expected = format_expected_progress( | ||
'Building registry.io/user/project:1.0.' | ||
'Steps: 0%| | 0/1' | ||
'Steps: 100%|██████████| 3/3' | ||
'The image registry.io/user/project:1.0 build is completed.' | ||
r'Building registry\.io/user/project:1\.0\.' | ||
r'Steps: 0%\| +\| 0/1' | ||
r'Steps: 100%\|█+\| 3/3' | ||
r'The image registry\.io/user/project:1\.0 build is completed\.' | ||
Comment on lines
+95
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
) | ||
assert expected in clean_progress_output(result.output) | ||
assert re.search(clean_progress_output(result.output), expected) | ||
|
||
|
||
def test_cli_custom_version(docker_client_mock, project_dir, test_mock): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,12 +110,16 @@ def test_get_image_registry(self): | |
class StatusUrlsTest(TestCase): | ||
|
||
def setUp(self): | ||
tmpdir = tempfile.gettempdir() | ||
os.chdir(tmpdir) | ||
self.status_file = os.path.join(tmpdir, STATUS_FILE_LOCATION) | ||
self.curdir = os.getcwd() | ||
self.tmp_dir = tempfile.gettempdir() | ||
os.chdir(self.tmp_dir) | ||
self.status_file = os.path.join(self.tmp_dir, STATUS_FILE_LOCATION) | ||
if os.path.exists(self.status_file): | ||
os.remove(self.status_file) | ||
|
||
def tearDown(self): | ||
os.chdir(self.curdir) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lack of this was causing trouble down the line when executing all tests. |
||
|
||
def test_load_status_url(self): | ||
self.assertRaises(NotFoundException, load_status_url, 0) | ||
# try with void file | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ def setUp(self): | |
self.curdir = os.getcwd() | ||
self.fake_requester = FakeRequester() | ||
deploy_egg.utils.make_deploy_request = self.fake_requester.fake_request | ||
self.tmp_dir = tempfile.mktemp(prefix="shub-test-deploy-eggs") | ||
self.tmp_dir = tempfile.mkdtemp(prefix="shub-test-deploy-eggs") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how it ever worked before. |
||
|
||
def tearDown(self): | ||
os.chdir(self.curdir) | ||
|
@@ -35,7 +35,8 @@ def tearDown(self): | |
def test_parses_project_information_correctly(self): | ||
# this test's assertions are based on the values | ||
# defined on this folder's setup.py file | ||
shutil.copytree('tests/samples/deploy_egg_sample_project/', self.tmp_dir) | ||
shutil.rmtree(self.tmp_dir) | ||
shutil.copytree('tests/samples/deploy_egg_sample_project', self.tmp_dir) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had started failing due to |
||
os.chdir(self.tmp_dir) | ||
|
||
data = self.call_main_and_check_request_data() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of
__file__
here was problematic due to some weird code callingsetup.py
withexec
, and given the purpose for which it was being used here, this seems like the cleaner fix to me.