[GRASS-git] [OSGeo/grass] 0a00df: grass.gunittest: Sync with unittest from Python 3....

Edouard Choinière noreply at github.com
Wed Aug 20 08:12:34 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 0a00df928b3f90012e90601b6f091c7c140de510
      https://github.com/OSGeo/grass/commit/0a00df928b3f90012e90601b6f091c7c140de510
  Author: Edouard Choinière <27212526+echoix at users.noreply.github.com>
  Date:   2025-08-20 (Wed, 20 Aug 2025)

  Changed paths:
    M python/grass/gunittest/Makefile
    M python/grass/gunittest/case.py
    M python/grass/gunittest/main.py
    A python/grass/gunittest/result.py
    M python/grass/gunittest/runner.py
    M python/grass/gunittest/utils.py

  Log Message:
  -----------
  grass.gunittest: Sync with unittest from Python 3.9 (#6200)

Prepare classes from gunittest to use multiple inheritance and be able to subclass from unittest, that would allow removing any code that we don't override. But before this, sync the code with Python 3.9's unittest implementation's, so the code is more similar and easier to compare. There will be less diff to review, and allows us to see that some newer unittest code effectively still works well with our codebase.

So, apart from copying over code that was copied some time ago, some code that is in a file named "result.py" was moved there, to follow the unittest implementation:
https://github.com/python/cpython/blob/06fc882eac0e59220a7b8b127a1e7babe0055d45/Lib/unittest/result.py#L24-L39

Other useful code to see is:
https://github.com/python/cpython/blob/06fc882eac0e59220a7b8b127a1e7babe0055d45/Lib/unittest/runner.py#L13-L125


* grass.gunittest: Place TestResult in result.py like Python 3.13

* grass.gunittest: Use safe_repr from unittest.util

* grass.gunittest: Use TestCase._formatMessage from unittest, changing output format

* gunittest: Ignore pylint C0103 in TestCase class

* gunittest: Make TestResult classes of runner.py subclasses of grass.gunittest.result.TestResult explicitly

* gunittest: Prepare TextTestResult for multiple inheritance by syncing its implementation with unittest.TextTestResult, following Python 3.9 implementation

* gunittest: Wrap TextTestResult stream with _WritelnDecorator when called by GrassTestProgram to follow unittest's TextTestResult implementation

* gunittest: Make GrassTestRunner stream argument default value None and use sys.stderr if None, like TextTestRunner implementation

* gunittest: Prepare GrassTestRunner to match unittest TextTestRunner implementation

* gunittest: Prepare GrassTestRunner to match unittest TextTestRunner implementation by adding other parameters

* Typo

* gunittest: Sync GrassTestProgram with unittest.TestProgram implementation of Python 3.9



To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications


More information about the grass-commit mailing list