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

Add test cases for dataclasses. #17909

Merged
merged 2 commits into from Jan 9, 2020
Merged

Conversation

@tirkarthi
Copy link
Contributor

tirkarthi commented Jan 8, 2020

  • Add test for ValueError to be raised when both default and default_factory are passed to a field.
  • Add test for repr output of field and dataclass params. These can be removed or made to assert basic structure of repr if it's very rigid.

Added missing coverage cases based on https://codecov.io/gh/python/cpython/src/2e6a8efa837410327b593dc83c57492253b1201e/Lib/dataclasses.py

Thanks

* Add test for repr output of field and dataclass params.
* Add test for ValueError to be raised when both default and default_factory are passed.
@@ -479,6 +498,18 @@ class C:
self.assertNotEqual(C(3), C(4, 10))
self.assertNotEqual(C(3, 10), C(4, 10))

def test_dataclass_params_repr(self):

This comment has been minimized.

Copy link
@ericvsmith

ericvsmith Jan 8, 2020

Member

This is testing an internal implementation detail. I'm not sure that this should be directly tested.

This comment has been minimized.

Copy link
@vstinner

vstinner Jan 8, 2020

Member

I have no opinion about keeping the test or not. But if you want to keep it, add @cpython_only decorator.

This comment has been minimized.

Copy link
@tirkarthi

tirkarthi Jan 9, 2020

Author Contributor

I have removed the test. I am not sure of a better way to access it publicly.

@ericvsmith ericvsmith merged commit eef1b02 into python:master Jan 9, 2020
8 checks passed
8 checks passed
Windows (x86)
Details
Windows (x64)
Details
macOS
Details
Ubuntu
Details
Azure Pipelines PR #20200109.14 succeeded
Details
bedevere/issue-number Issue report skipped
bedevere/news "skip news" label found
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@miss-islington

This comment has been minimized.

Copy link

miss-islington commented Jan 9, 2020

Thanks @tirkarthi for the PR, and @ericvsmith for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒🤖

@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Jan 9, 2020

@ericvsmith: Please replace # with GH- in the commit message next time. Thanks!

miss-islington added a commit to miss-islington/cpython that referenced this pull request Jan 9, 2020
* Add test cases for dataclasses.

* Add test for repr output of field.
* Add test for ValueError to be raised when both default and default_factory are passed.
(cherry picked from commit eef1b02)

Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Jan 9, 2020

GH-17919 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit to miss-islington/cpython that referenced this pull request Jan 9, 2020
* Add test cases for dataclasses.

* Add test for repr output of field.
* Add test for ValueError to be raised when both default and default_factory are passed.
(cherry picked from commit eef1b02)

Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Jan 9, 2020

GH-17920 is a backport of this pull request to the 3.7 branch.

miss-islington added a commit that referenced this pull request Jan 10, 2020
* Add test cases for dataclasses.

* Add test for repr output of field.
* Add test for ValueError to be raised when both default and default_factory are passed.
(cherry picked from commit eef1b02)


Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>

Automerge-Triggered-By: @ericvsmith
miss-islington added a commit that referenced this pull request Jan 10, 2020
* Add test cases for dataclasses.

* Add test for repr output of field.
* Add test for ValueError to be raised when both default and default_factory are passed.
(cherry picked from commit eef1b02)


Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>

Automerge-Triggered-By: @ericvsmith
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.