Convert Unittest testcases with setup/teardown to fixtures by akx · Pull Request #1240 · python-babel/babel · GitHub
Skip to content

Convert Unittest testcases with setup/teardown to fixtures#1240

Merged
akx merged 3 commits into
masterfrom
unwrap-testcases
Dec 29, 2025
Merged

Convert Unittest testcases with setup/teardown to fixtures#1240
akx merged 3 commits into
masterfrom
unwrap-testcases

Conversation

@akx

@akx akx commented Dec 25, 2025

Copy link
Copy Markdown
Member

This PR follows up on #1241 to unwrap remaining unittest.TestCases to use Pytest fixtures.

@codecov

codecov Bot commented Dec 25, 2025

Copy link
Copy Markdown

@akx akx force-pushed the unwrap-testcases branch 2 times, most recently from 63185e8 to c06b041 Compare December 25, 2025 15:22
@akx akx requested a review from Copilot December 25, 2025 15:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the test suite by converting unittest.TestCase-based tests to plain pytest functions. The main changes include:

  • Replacing setUp()/tearDown() methods with pytest fixtures
  • Converting class-based tests to standalone functions
  • Splitting files with multiple TestCase classes into separate modules
  • Creating a new tests/messages/frontend/ package to organize frontend-related tests

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_util.py Converted FixedOffsetTimezoneTestCase class to standalone test functions
tests/test_plural_rule_parser.py New file containing plural rule parser tests extracted from test_plural.py
tests/test_plural.py Removed PluralRuleParserTestCase, extracted tests to new file, converted TestNextTokenTestCase to functions
tests/test_numbers_parsing.py New file containing number parsing tests extracted from test_numbers.py
tests/test_numbers_format_decimal.py New file containing decimal formatting tests extracted from test_numbers.py
tests/test_numbers.py Removed FormatDecimalTestCase and NumberParsingTestCase, kept only top-level test functions
tests/test_localedata.py Converted MergeResolveTestCase to standalone test functions
tests/test_dates.py Minor formatting adjustment (added blank line)
tests/messages/utils.py Added Distribution class moved from test_frontend.py
tests/messages/test_pofile_write.py New file containing write tests extracted from test_pofile.py
tests/messages/test_pofile_read.py New file containing read tests extracted from test_pofile.py
tests/messages/test_pofile.py Removed ReadPoTestCase and WritePoTestCase, kept utility test functions
tests/messages/test_mofile.py Converted ReadMoTestCase and WriteMoTestCase to standalone functions with fixture
tests/messages/test_extract_python.py New file containing Python extraction tests extracted from test_extract.py
tests/messages/test_extract.py Removed ExtractPythonTestCase, kept ExtractTestCase tests as functions
tests/messages/test_checkers.py Converted CheckersTestCase and TestPythonFormat to standalone test functions
tests/messages/test_catalog.py Converted MessageTestCase and CatalogTestCase to standalone test functions
tests/messages/frontend/test_init.py New file containing InitCatalog tests from test_frontend.py
tests/messages/frontend/test_extract.py New file containing ExtractMessages tests from test_frontend.py
tests/messages/frontend/test_frontend.py New file containing general frontend tests from test_frontend.py

The refactoring is well-executed and follows pytest conventions. The tests maintain their original behavior while adopting a more modern and idiomatic pytest style.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@akx akx force-pushed the unwrap-testcases branch from c06b041 to 802382f Compare December 25, 2025 16:05
@akx akx changed the title Unwrap testcases Convert Pytest testcases with setup/teardown to fixtures Dec 25, 2025
@akx akx changed the title Convert Pytest testcases with setup/teardown to fixtures Convert Unittest testcases with setup/teardown to fixtures Dec 25, 2025
@akx akx force-pushed the unwrap-testcases branch from 802382f to b3fcb5b Compare December 25, 2025 16:15
@akx akx marked this pull request as ready for review December 29, 2025 10:32
@akx

akx commented Dec 29, 2025

Copy link
Copy Markdown
Member Author

@akx akx merged commit 0c4f378 into master Dec 29, 2025
38 checks passed
@akx akx deleted the unwrap-testcases branch December 29, 2025 11:11
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.

2 participants