Skip to content

Commit 61fa3c7

Browse files
committed
Make feature tests less specific
1 parent c0b2ac1 commit 61fa3c7

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

features/check-git-repo.feature

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,10 @@ Feature: Checking dependencies from a git repository
217217
url: https://github.com/dfetch-org/test-repo-private.git
218218
"""
219219
When I run "dfetch check"
220-
Then the output shows
220+
Then the output starts with:
221221
"""
222222
Dfetch (0.10.0)
223223
>>>git ls-remote --heads --tags https://github.com/dfetch-org/test-repo-private.git<<< returned 128:
224-
fatal: could not read Username for 'https://github.com': terminal prompts disabled
225224
"""
226225

227226
Scenario: SSH issues
@@ -235,13 +234,8 @@ Feature: Checking dependencies from a git repository
235234
url: git@github.com:dfetch-org/test-repo-private.git
236235
"""
237236
When I run "dfetch check"
238-
Then the output shows
237+
Then the output starts with:
239238
"""
240239
Dfetch (0.10.0)
241240
>>>git ls-remote --heads --tags git@github.com:dfetch-org/test-repo-private.git<<< returned 128:
242-
Host key verification failed.
243-
fatal: Could not read from remote repository.
244-
245-
Please make sure you have the correct access rights
246-
and the repository exists.
247241
"""

features/steps/generic_steps.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,17 @@ def multisub(patterns: List[Tuple[Pattern[str], str]], text: str) -> str:
247247
return text
248248

249249

250+
@then("the output starts with:")
251+
def step_impl(context):
252+
check_output(context, line_count=len(context.text.splitlines()))
253+
254+
250255
@then("the output shows")
251256
def step_impl(context):
257+
check_output(context)
258+
259+
260+
def check_output(context, line_count=None):
252261
expected_text = multisub(
253262
patterns=[
254263
(git_hash, r"\1[commit hash]\2"),
@@ -273,7 +282,9 @@ def step_impl(context):
273282
text=context.cmd_output,
274283
)
275284

276-
diff = difflib.ndiff(actual_text.splitlines(), expected_text.splitlines())
285+
diff = difflib.ndiff(
286+
actual_text.splitlines()[:line_count], expected_text.splitlines()
287+
)
277288

278289
diffs = [x for x in diff if x[0] in ("+", "-")]
279290
if diffs:

0 commit comments

Comments
 (0)