-
Notifications
You must be signed in to change notification settings - Fork 13
Refactor split test #927
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
Refactor split test #927
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 | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -216,6 +216,13 @@ def assert_success(self, result: click.testing.Result): | |||||||||||||||||||||||||||||||||||
| def assert_exit_code(self, result: click.testing.Result, expected: int): | ||||||||||||||||||||||||||||||||||||
| self.assertEqual(result.exit_code, expected, result.stdout) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def assert_contents(self, file_path: str, content: str): | ||||||||||||||||||||||||||||||||||||
| with open(file_path) as f: | ||||||||||||||||||||||||||||||||||||
| self.assertEqual(f.read(), content) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def assert_file_exists(self, file_path: str, exists: bool = True): | ||||||||||||||||||||||||||||||||||||
| self.assertEqual(Path(file_path).exists(), exists) | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+223
to
+224
Contributor
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. 🛠️ Refactor suggestion Improve documentation and error messages of The method would benefit from better documentation and more descriptive assertion messages: - def assert_file_exists(self, file_path: str, exists: bool = True):
- self.assertEqual(Path(file_path).exists(), exists)
+ def assert_file_exists(self, file_path: str, exists: bool = True) -> None:
+ """Assert that a file exists or does not exist.
+
+ Args:
+ file_path: Path to the file to check
+ exists: If True, assert the file exists. If False, assert it doesn't exist
+
+ Raises:
+ AssertionError: If the file existence doesn't match expectations
+ """
+ file_exists = Path(file_path).exists()
+ if exists:
+ self.assertTrue(file_exists, f"Expected file to exist: {file_path}")
+ else:
+ self.assertFalse(file_exists, f"Expected file to not exist: {file_path}")📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def find_request(self, url_suffix: str, n: int = 0): | ||||||||||||||||||||||||||||||||||||
| '''Find the first (or n-th, if specified) request that matches the given suffix''' | ||||||||||||||||||||||||||||||||||||
| for call in responses.calls: | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
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.
🛠️ Refactor suggestion
Enhance robustness and documentation of
assert_contents.The method could benefit from improved error handling and documentation:
📝 Committable suggestion