Skip to content

Commit

Permalink
more git history tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hjwp committed Mar 5, 2019
1 parent 6120027 commit 4652910
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = --tb=short
23 changes: 18 additions & 5 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,31 @@
"appendix_project_structure",
]

@pytest.fixture(scope='session')
def git_log():

def git_log(chapter):
return subprocess.run(
['git', 'log', 'origin/master', '--oneline', '--decorate'],
['git', 'log', f'origin/{chapter}', '--oneline', '--decorate'],
cwd=Path(__file__).parent / 'code',
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
check=True
).stdout.decode()

@pytest.fixture(scope='session')
def master_log():
return git_log('master')

@pytest.mark.parametrize('chapter', CHAPTERS)
def test_git_history(git_log, chapter):
assert f'origin/{chapter}' in git_log
def test_master_has_all_chapters_in_its_history(master_log, chapter):
assert f'origin/{chapter}' in master_log


@pytest.mark.parametrize('chapter', CHAPTERS)
def test_each_chapter_follows_the_last(chapter):
chapter_no = CHAPTERS.index(chapter)
if chapter_no == 0:
return
previous = CHAPTERS[chapter_no - 1]
assert f'origin/{previous}' in git_log(chapter), f'{chapter} did not follow {previous}'


@pytest.mark.parametrize('chapter', CHAPTERS)
Expand Down

0 comments on commit 4652910

Please sign in to comment.