Skip to content

Run unittest tests with unittest#19121

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
jeremy-audet:unittest
Jul 16, 2024
Merged

Run unittest tests with unittest#19121
wing328 merged 1 commit into
OpenAPITools:masterfrom
jeremy-audet:unittest

Conversation

@jeremy-audet
Copy link
Copy Markdown
Contributor

The unit tests in the following directories are written to unittest, not pytest:

  • samples/client/echo_api/python/
  • samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/

If pytest is told to execute these tests, it will log warnings about being unable to collect certain tests.

@jeremy-audet jeremy-audet requested a review from jimschubert as a code owner July 9, 2024 18:40
@jeremy-audet
Copy link
Copy Markdown
Contributor Author

Split from #19068

ping python tech committee members: @cbornet @tomplus @krjakbrjak @fa0311 @multani

The unit tests in the following directories are written to unittest, not
pytest:

* `samples/client/echo_api/python/`
* `samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/`

If pytest is told to execute these tests, it will log warnings about
being unable to collect certain tests.
@multani
Copy link
Copy Markdown
Contributor

multani commented Jul 11, 2024

@Ichimonji10 do you have the list of warnings generated?

AFAIK, pytest should be able to execute unittest without any warnings, by default.

@jeremy-audet
Copy link
Copy Markdown
Contributor Author

jeremy-audet commented Jul 11, 2024

Here's the warnings emitted when I locally run python -m pytest. Similar output can be seen in pipeline results.

openapi_client/models/test_form_object_multipart_request_marker.py:26
  /home/jaudet/code/openapi-generator/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py:26: PytestCollectionWarning: cannot collect test class 'TestFormObjectMultipartRequestMarker' because it has a __init__ constructor (from: openapi_client/models/test_form_object_multipart_request_marker.py)
    class TestFormObjectMultipartRequestMarker(BaseModel):

openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py:26
  /home/jaudet/code/openapi-generator/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py:26: PytestCollectionWarning: cannot collect test class 'TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter' because it has a __init__ constructor (from: openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py)
    class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseModel):

openapi_client/models/test_query_style_form_explode_true_array_integer_query_object_parameter.py:26
  /home/jaudet/code/openapi-generator/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_integer_query_object_parameter.py:26: PytestCollectionWarning: cannot collect test class 'TestQueryStyleFormExplodeTrueArrayIntegerQueryObjectParameter' because it has a __init__ constructor (from: openapi_client/models/test_query_style_form_explode_true_array_integer_query_object_parameter.py)
    class TestQueryStyleFormExplodeTrueArrayIntegerQueryObjectParameter(BaseModel):

openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py:26
  /home/jaudet/code/openapi-generator/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py:26: PytestCollectionWarning: cannot collect test class 'TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter' because it has a __init__ constructor (from: openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py)
    class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):

openapi_client/models/test_form_object_multipart_request_marker.py:26
  /home/jaudet/code/openapi-generator/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py:26: PytestCollectionWarning: cannot collect test class 'TestFormObjectMultipartRequestMarker' because it has a __init__ constructor (from: test/test_test_form_object_multipart_request_marker.py)
    class TestFormObjectMultipartRequestMarker(BaseModel):

openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py:26
  /home/jaudet/code/openapi-generator/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py:26: PytestCollectionWarning: cannot collect test class 'TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter' because it has a __init__ constructor (from: test/test_test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py)
    class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseModel):

openapi_client/models/test_query_style_form_explode_true_array_integer_query_object_parameter.py:26
  /home/jaudet/code/openapi-generator/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_integer_query_object_parameter.py:26: PytestCollectionWarning: cannot collect test class 'TestQueryStyleFormExplodeTrueArrayIntegerQueryObjectParameter' because it has a __init__ constructor (from: test/test_test_query_style_form_explode_true_array_integer_query_object_parameter.py)
    class TestQueryStyleFormExplodeTrueArrayIntegerQueryObjectParameter(BaseModel):

openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py:26
  /home/jaudet/code/openapi-generator/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py:26: PytestCollectionWarning: cannot collect test class 'TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter' because it has a __init__ constructor (from: test/test_test_query_style_form_explode_true_array_string_query_object_parameter.py)
    class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):

Even if pytest can run unittest-style tests, I don't see why that would be done, as no pytest features are being used AFAIK. Switching to unittest means fewer warnings and (at least) one less dependency.

Copy link
Copy Markdown
Contributor

@multani multani left a comment

Choose a reason for hiding this comment

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

We can merge this change.

Overall, I think unittest usage would be removed in favor of simpler pytest-based tests, but that's a much larger change.

@wing328 wing328 merged commit c8587bb into OpenAPITools:master Jul 16, 2024
@jeremy-audet jeremy-audet deleted the unittest branch July 16, 2024 15:55
@wing328 wing328 added this to the 7.8.0 milestone Aug 18, 2024
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