christianhelle / autofaker

Python library designed to minimize the setup/arrange phase of your unit tests
MIT License
6 stars 3 forks source link

Add Enum support #7

Closed christianhelle closed 1 year ago

christianhelle commented 1 year ago

This implements #6

Example usage:

from enum import Enum

class Weekday(Enum):
    MONDAY = 1
    TUESDAY = 2
    WEDNESDAY = 3
    THURSDAY = 4
    FRIDAY = 5
    SATURDAY = 6
    SUNDAY = 7
from autofaker import autodata

@autodata(Weekday)
def test_create_enum_class_returns_not_none(sut):
    assert sut is not None

@autodata(Weekday)
def test_create_enum_class_returns_instance(sut):
    assert isinstance(sut, Weekday)
import unittest
from autofaker import Autodata

class AnonymousWeekdayTestCase(unittest.TestCase):

    def test_create_enum_class_returns_not_none(self):
        self.assertIsNotNone(Autodata.create(Weekday))

    def test_create_enum_class_returns_instance(self):
        self.assertIsInstance(Autodata.create(Weekday), Weekday)
christianhelle commented 1 year ago

Does this work for you @TheRobotCarlson ?

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication