-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
193 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,26 +4,30 @@ | |
import pytest | ||
from helper import TempRepository | ||
|
||
def create_repo(dirname = None): | ||
|
||
def create_repo(dirname=None): | ||
repo = TempRepository(dirname) | ||
tmp_file_a = repo.create_tmp_file() | ||
tmp_file_b = repo.create_tmp_file() | ||
repo.create_tmp_file() | ||
repo.create_tmp_file() | ||
repo.switch_cwd_under_repo() | ||
return repo | ||
|
||
|
||
def init_repo_git_status(repo): | ||
git = repo.get_repo_git() | ||
git.add(".") | ||
git.config("--local", "user.name", "test") | ||
git.config("--local", "user.email", "[email protected]") | ||
git.commit("-m", "chore: initial commit") | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def temp_repo(): | ||
repo = create_repo() | ||
init_repo_git_status(repo) | ||
return repo | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def named_temp_repo(request): | ||
dirname = request.param | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import os, subprocess | ||
|
||
expected_authors_list = "test <[email protected]>\ntestagain <[email protected]>\n" | ||
expected_authors_list = ( | ||
"test <[email protected]>\ntestagain <[email protected]>\n" | ||
) | ||
expected_authors_list_without_email = "test\ntestagain\n" | ||
authors_file = "AUTHORS" | ||
|
||
|
||
class TestGitAuthors: | ||
def test_init(self, temp_repo): | ||
git = temp_repo.get_repo_git() | ||
|
@@ -18,16 +19,16 @@ def test_init(self, temp_repo): | |
git.commit("-m", "test: add data B") | ||
|
||
def test_output_authors_has_email_without_any_parameter(self, temp_repo): | ||
git = temp_repo.get_repo_git() | ||
rs = temp_repo.invoke_extras_command("authors") | ||
temp_repo.get_repo_git() | ||
temp_repo.invoke_extras_command("authors") | ||
with open(authors_file) as f: | ||
content = f.read() | ||
print(content) | ||
print(expected_authors_list) | ||
assert content == expected_authors_list | ||
|
||
def test_list_authors_has_email_defaultly(self, temp_repo): | ||
git = temp_repo.get_repo_git() | ||
temp_repo.get_repo_git() | ||
actual = temp_repo.invoke_extras_command("authors", "--list") | ||
actual = actual.stdout.decode() | ||
assert actual == expected_authors_list | ||
|
@@ -36,7 +37,7 @@ def test_list_authors_has_email_defaultly(self, temp_repo): | |
assert actual == expected_authors_list | ||
|
||
def test_list_authors_has_not_email(self, temp_repo): | ||
git = temp_repo.get_repo_git() | ||
temp_repo.get_repo_git() | ||
actual = temp_repo.invoke_extras_command("authors", "--list", "--no-email") | ||
actual = actual.stdout.decode() | ||
assert actual == expected_authors_list_without_email | ||
|
Oops, something went wrong.