Skip to content

Conversation

@tirkarthi
Copy link
Member

  • 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.
self.assertNotEqual(C(3), C(4, 10))
self.assertNotEqual(C(3, 10), C(4, 10))

def test_dataclass_params_repr(self):
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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
@miss-islington
Copy link
Contributor

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
Copy link

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

miss-islington pushed 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
Copy link

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

miss-islington pushed 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
Copy link

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
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Jan 31, 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip issue skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants