Skip to content
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

PR: Remove BaseTestCase from testsuite/ #7742

Merged
merged 6 commits into from
Jul 29, 2023

Conversation

bigtedde
Copy link
Contributor

@bigtedde bigtedde commented Jul 26, 2023

Now that the ArchiverBaseTestCase has been removed from testsuite/archiver/__init__.py, I would now like to remove BaseTestCase from the testsuite/__init__.py. After @ThomasWaldmann's recent update to the BaseTestCasehere, all that remains are a few assert methods that seem superfluous and could be replaced with the built-in python asserts.

@bigtedde bigtedde marked this pull request as draft July 26, 2023 19:38
@codecov-commenter
Copy link

codecov-commenter commented Jul 26, 2023

Codecov Report

Merging #7742 (a09c8ad) into master (5df49ee) will increase coverage by 0.01%.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #7742      +/-   ##
==========================================
+ Coverage   83.65%   83.67%   +0.01%     
==========================================
  Files          66       66              
  Lines       11915    11915              
  Branches     2159     2159              
==========================================
+ Hits         9968     9970       +2     
+ Misses       1371     1370       -1     
+ Partials      576      575       -1     

see 1 file with indirect coverage changes

@bigtedde
Copy link
Contributor Author

bigtedde commented Jul 26, 2023

@ThomasWaldmann After these committed changes, there are only four test files remaining in the testsuite folder that use BaseTestCase. One is /platform.py, which uses BaseTestCase and a lot of unittest, so I was considering making this its own PR. The other three are files that include tests used in selftest, these are:

  1. /hashindex.py
  2. /crypto.py
  3. /chunker.py

I feel that removing the BaseTestCase from these would be straightforward and shouldn't impact the selftest themselves as I would not be introducing any pytest or changing any functionality. However, I wanted to check with you first to see if you are fine with me doing this.

These are the last few files standing between BaseTestCase and complete removal :)

@bigtedde bigtedde changed the title PR: Removed BaseTestCase from testsuite/archive.py PR: Remove BaseTestCase from testsuite/ Jul 26, 2023
Copy link
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. some more places could use parametrize I guess.

for path in rejected_dotdot_paths:
with pytest.raises(ValueError, match="unexpected '..' element in path"):
make_path_safe(path)
def test_remove_dot_prefixes():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original name had dotdot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seen this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've got this corrected locally. Adding some additional parameterization to this file and will push soon 🙂

@bigtedde
Copy link
Contributor Author

looks good. some more places could use parametrize I guess.

I will make that happen. Also, are you okay with me removing BaseTestCase from the 3 files in selftest? Being careful to not change any functionality and not introducing pytest.

@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented Jul 27, 2023

Maybe stay away from the selftest stuff for now until the other stuff is done.

@bigtedde
Copy link
Contributor Author

Cleaned up and parametrized as needed in helpers.py

@bigtedde bigtedde marked this pull request as ready for review July 28, 2023 21:14
Copy link
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look much better with parametrize now.

Just the imports somehow got ugly, IMHO.

Comment on lines 27 to 62
from ..helpers import (
archivename_validator,
bin_to_hex,
binary_to_json,
chunkit,
clean_lines,
dash_open,
eval_escapes,
format_file_size,
parse_file_size,
format_timedelta,
format_line,
PlaceholderError,
format_timedelta,
get_base_dir,
get_cache_dir,
get_config_dir,
get_keys_dir,
get_runtime_dir,
get_security_dir,
interval,
is_slow_msgpack,
iter_separated,
make_path_safe,
msgpack,
parse_file_size,
parse_timestamp,
partial_format,
popen_with_error_handling,
remove_dotdot_prefixes,
replace_placeholders,
safe_ns,
safe_s,
safe_unlink,
swidth_slice,
text_to_json,
text_validator,
yes,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That stuff uses to be grouped (more or less what belongs together somehow).

Or did you somehow trigger black doing this?

I rather prefer the horizontal grouped form, less scrolling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get this changed back to the original 🙂

@bigtedde
Copy link
Contributor Author

@ThomasWaldmann As far as removing BaseTestCase from the selftest items - is this something I'd be good to work on now, or should we hold off?

Copy link
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ThomasWaldmann ThomasWaldmann merged commit 1e7dec1 into borgbackup:master Jul 29, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants