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

Class-level variable data #46

Open
iartarisi opened this issue Dec 12, 2016 · 4 comments
Open

Class-level variable data #46

iartarisi opened this issue Dec 12, 2016 · 4 comments

Comments

@iartarisi
Copy link

I would like to suggest adding some sort of class-level ddt.data I will write an example to show what I mean:

def is_valid_metavar(metavar):
    return metavar in ['foo', 'bar', 'baz']


@ddt.ddt
@ddt.data('foo', 'bar')
class TestMetavars(unittest.TestCase):
    def test_valid(self, metavar):
        self.assertTrue(is_valid_metavar(metavar))

    def test_something_else(self, metavar):
        self.assertEqual(len(metavar), 3)

    # this overrides the previous variable
    @ddt.data('ulf', 'flup')
    def test_invalid(self, metavar):
        self.assertFalse(is_valid_metavar(metavar))

    # or (better?) without implicit overrides
    @ddt.data(
        {'metavar': 'ulf'},
        {'metavar': 'flup'})
    def test_invalid(self, metavar):
        self.assertFalse(is_valid_metavar(metavar))

I would be happy to send a pull request implementing this if you're happy with the API. This should be a backwards-compatible change.

@wswld
Copy link
Contributor

wswld commented May 25, 2018

Are you still interested in this?

@iartarisi
Copy link
Author

Probably not. Too late. Sorry.

@ntindle
Copy link
Contributor

ntindle commented Jul 17, 2019

This would be very useful

@wswld
Copy link
Contributor

wswld commented Jul 18, 2019 via email

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

No branches or pull requests

3 participants