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 percent changes to test results and flakes aggregates #829

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

joseph-sentry
Copy link
Contributor

This adds PercentChange fields to both the TestResultsAggregates
and the FlakeAggregates. These work by getting the aggregates
for the previous historical period and comparing them with the
ones for the current historical period and getting a percentage difference.

this commit also adds the LastDuration field to the TestResult
GQL model. The reason we're using latest_run and not the updated_at
field of the object is because in the future we want to parse the
timestamp from the JUnit XML file so latest_run will be tied to that
and not the time at which we process the test results.
- TestResultsHeaders represents the information displayed in the Test
Analytics UI that is related to test results, total duration of tests,
accumulated duration of the 5% slowest tests, total number of failures,
and total number of skips

- a field of type TestResultsHeaders was added to the Repository model
- rename the TestResultsHeaders GQL model to TestResultsAggregates
- create the FlakeAggregates that contains flakeCount and flakeRate
  and uses the flaky_failure_count field from the DailyTestRollup
we want to be able to filter by flaky tests, failed tests and the
slowest tests, because we want the clickable headers in the UI
This adds PercentChange fields to both the TestResultsAggregates
and the FlakeAggregates. These work by getting the aggregates
for the previous historical period and comparing them with the
ones for the current historical period and getting a percentage
difference.
@codecov-staging
Copy link

❌ 29 Tests Failed:

Tests completed Failed Passed Skipped
2297 29 2268 6
View the top 3 failed tests by shortest run time
graphql_api.tests.test_repository.TestFetchRepository test_desc_failure_rate_ordering_on_test_results
Stack Traces | 0.31s run time
self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_failure_rate_ordering_on_test_results>

    def test_desc_failure_rate_ordering_on_test_results(self) -> None:
        repo = RepositoryFactory(author=self.owner, active=True, private=True)
        test = TestFactory(repository=repo)
>       _ = DailyTestRollupFactory(
            test=test,
            date=datetime.date.today() - datetime.timedelta(days=1),
            repoid=repo.repoid,
            pass_count=1,
            fail_count=1,
        )

graphql_api/tests/test_repository.py:1229: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
.../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
.../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
.../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
.../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
.../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
.../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
kwargs = {'flaky_fail_count': 0}
cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
_DEFERRED = <Deferred field>
fields_iter = <tuple_iterator object at 0x7fdde4209360>
val = ['123', '456', '789']
field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
is_related_object = False, rel_obj = <Test: Test object (14)>
property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
        # Alias some things as locals to avoid repeat global lookups
        cls = self.__class__
        opts = self._meta
        _setattr = setattr
        _DEFERRED = DEFERRED
        if opts.abstract:
            raise TypeError("Abstract models cannot be instantiated.")
    
        pre_init.send(sender=cls, args=args, kwargs=kwargs)
    
        # Set up the storage for instance state
        self._state = ModelState()
    
        # There is a rather weird disparity here; if kwargs, it's set, then args
        # overrides it. It should be one or the other; don't duplicate the work
        # The reason for the kwargs check is that standard iterator passes in by
        # args, and instantiation for iteration is 33% faster.
        if len(args) > len(opts.concrete_fields):
            # Daft, but matches old exception sans the err msg.
            raise IndexError("Number of args exceeds number of fields")
    
        if not kwargs:
            fields_iter = iter(opts.concrete_fields)
            # The ordering of the zip calls matter - zip throws StopIteration
            # when an iter throws it. So if the first iter throws it, the second
            # is *not* consumed. We rely on this, so don't change the order
            # without changing the logic.
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
        else:
            # Slower, kwargs-ready version.
            fields_iter = iter(opts.fields)
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
                if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
                    raise TypeError(
                        f"{cls.__qualname__}() got both positional and "
                        f"keyword arguments for field '{field.name}'."
                    )
    
        # Now we're left with the unprocessed fields that *must* come from
        # keywords, or default.
    
        for field in fields_iter:
            is_related_object = False
            # Virtual field
            if field.attname not in kwargs and field.column is None:
                continue
            if kwargs:
                if isinstance(field.remote_field, ForeignObjectRel):
                    try:
                        # Assume object instance was passed in.
                        rel_obj = kwargs.pop(field.name)
                        is_related_object = True
                    except KeyError:
                        try:
                            # Object instance wasn't passed in -- must be an ID.
                            val = kwargs.pop(field.attname)
                        except KeyError:
                            val = field.get_default()
                else:
                    try:
                        val = kwargs.pop(field.attname)
                    except KeyError:
                        # This is done with an exception rather than the
                        # default argument on pop because we don't want
                        # get_default() to be evaluated, and then not used.
                        # Refs #12057.
                        val = field.get_default()
            else:
                val = field.get_default()
    
            if is_related_object:
                # If we are passed a related instance, set it using the
                # field.name instead of field.attname (e.g. "user" instead of
                # "user_id") so that the object gets properly cached (and type
                # checked) by the RelatedObjectDescriptor.
                if rel_obj is not _DEFERRED:
                    _setattr(self, field.name, rel_obj)
            else:
                if val is not _DEFERRED:
                    _setattr(self, field.attname, val)
    
        if kwargs:
            property_names = opts._property_names
            unexpected = ()
            for prop, value in kwargs.items():
                # Any remaining kwargs must correspond to properties or virtual
                # fields.
                if prop in property_names:
                    if value is not _DEFERRED:
                        _setattr(self, prop, value)
                else:
                    try:
                        opts.get_field(prop)
                    except FieldDoesNotExist:
                        unexpected += (prop,)
                    else:
                        if value is not _DEFERRED:
                            _setattr(self, prop, value)
            if unexpected:
                unexpected_names = ", ".join(repr(n) for n in unexpected)
>               raise TypeError(
                    f"{cls.__name__}() got unexpected keyword arguments: "
                    f"{unexpected_names}"
                )
E               TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

.../local/lib/python3.12.../db/models/base.py:567: TypeError
graphql_api.tests.test_repository.TestFetchRepository test_commits_failed_ordering_on_test_results
Stack Traces | 0.311s run time
self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_commits_failed_ordering_on_test_results>

    def test_commits_failed_ordering_on_test_results(self) -> None:
        repo = RepositoryFactory(author=self.owner, active=True, private=True)
        test = TestFactory(repository=repo)
>       _ = DailyTestRollupFactory(
            test=test,
            date=datetime.date.today() - datetime.timedelta(days=1),
            repoid=repo.repoid,
            commits_where_fail=["1"],
        )

graphql_api/tests/test_repository.py:989: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
.../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
.../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
.../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
.../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
.../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
.../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
kwargs = {'flaky_fail_count': 0}
cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
_DEFERRED = <Deferred field>
fields_iter = <tuple_iterator object at 0x7fdde4e2a530>, val = ['1']
field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
is_related_object = False, rel_obj = <Test: Test object (11)>
property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
        # Alias some things as locals to avoid repeat global lookups
        cls = self.__class__
        opts = self._meta
        _setattr = setattr
        _DEFERRED = DEFERRED
        if opts.abstract:
            raise TypeError("Abstract models cannot be instantiated.")
    
        pre_init.send(sender=cls, args=args, kwargs=kwargs)
    
        # Set up the storage for instance state
        self._state = ModelState()
    
        # There is a rather weird disparity here; if kwargs, it's set, then args
        # overrides it. It should be one or the other; don't duplicate the work
        # The reason for the kwargs check is that standard iterator passes in by
        # args, and instantiation for iteration is 33% faster.
        if len(args) > len(opts.concrete_fields):
            # Daft, but matches old exception sans the err msg.
            raise IndexError("Number of args exceeds number of fields")
    
        if not kwargs:
            fields_iter = iter(opts.concrete_fields)
            # The ordering of the zip calls matter - zip throws StopIteration
            # when an iter throws it. So if the first iter throws it, the second
            # is *not* consumed. We rely on this, so don't change the order
            # without changing the logic.
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
        else:
            # Slower, kwargs-ready version.
            fields_iter = iter(opts.fields)
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
                if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
                    raise TypeError(
                        f"{cls.__qualname__}() got both positional and "
                        f"keyword arguments for field '{field.name}'."
                    )
    
        # Now we're left with the unprocessed fields that *must* come from
        # keywords, or default.
    
        for field in fields_iter:
            is_related_object = False
            # Virtual field
            if field.attname not in kwargs and field.column is None:
                continue
            if kwargs:
                if isinstance(field.remote_field, ForeignObjectRel):
                    try:
                        # Assume object instance was passed in.
                        rel_obj = kwargs.pop(field.name)
                        is_related_object = True
                    except KeyError:
                        try:
                            # Object instance wasn't passed in -- must be an ID.
                            val = kwargs.pop(field.attname)
                        except KeyError:
                            val = field.get_default()
                else:
                    try:
                        val = kwargs.pop(field.attname)
                    except KeyError:
                        # This is done with an exception rather than the
                        # default argument on pop because we don't want
                        # get_default() to be evaluated, and then not used.
                        # Refs #12057.
                        val = field.get_default()
            else:
                val = field.get_default()
    
            if is_related_object:
                # If we are passed a related instance, set it using the
                # field.name instead of field.attname (e.g. "user" instead of
                # "user_id") so that the object gets properly cached (and type
                # checked) by the RelatedObjectDescriptor.
                if rel_obj is not _DEFERRED:
                    _setattr(self, field.name, rel_obj)
            else:
                if val is not _DEFERRED:
                    _setattr(self, field.attname, val)
    
        if kwargs:
            property_names = opts._property_names
            unexpected = ()
            for prop, value in kwargs.items():
                # Any remaining kwargs must correspond to properties or virtual
                # fields.
                if prop in property_names:
                    if value is not _DEFERRED:
                        _setattr(self, prop, value)
                else:
                    try:
                        opts.get_field(prop)
                    except FieldDoesNotExist:
                        unexpected += (prop,)
                    else:
                        if value is not _DEFERRED:
                            _setattr(self, prop, value)
            if unexpected:
                unexpected_names = ", ".join(repr(n) for n in unexpected)
>               raise TypeError(
                    f"{cls.__name__}() got unexpected keyword arguments: "
                    f"{unexpected_names}"
                )
E               TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

.../local/lib/python3.12.../db/models/base.py:567: TypeError
graphql_api.tests.test_repository.TestFetchRepository test_desc_avg_duration_ordering_on_test_results
Stack Traces | 0.313s run time
self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_avg_duration_ordering_on_test_results>

    def test_desc_avg_duration_ordering_on_test_results(self) -> None:
        repo = RepositoryFactory(author=self.owner, active=True, private=True)
        test = TestFactory(repository=repo)
>       _ = DailyTestRollupFactory(
            test=test,
            date=datetime.date.today() - datetime.timedelta(days=1),
            repoid=repo.repoid,
            avg_duration_seconds=1,
        )

graphql_api/tests/test_repository.py:1159: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
.../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
.../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
.../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
.../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
.../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
.../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
kwargs = {'flaky_fail_count': 0}
cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
_DEFERRED = <Deferred field>
fields_iter = <tuple_iterator object at 0x7fdde4520af0>
val = ['123', '456', '789']
field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
is_related_object = False, rel_obj = <Test: Test object (12)>
property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
        # Alias some things as locals to avoid repeat global lookups
        cls = self.__class__
        opts = self._meta
        _setattr = setattr
        _DEFERRED = DEFERRED
        if opts.abstract:
            raise TypeError("Abstract models cannot be instantiated.")
    
        pre_init.send(sender=cls, args=args, kwargs=kwargs)
    
        # Set up the storage for instance state
        self._state = ModelState()
    
        # There is a rather weird disparity here; if kwargs, it's set, then args
        # overrides it. It should be one or the other; don't duplicate the work
        # The reason for the kwargs check is that standard iterator passes in by
        # args, and instantiation for iteration is 33% faster.
        if len(args) > len(opts.concrete_fields):
            # Daft, but matches old exception sans the err msg.
            raise IndexError("Number of args exceeds number of fields")
    
        if not kwargs:
            fields_iter = iter(opts.concrete_fields)
            # The ordering of the zip calls matter - zip throws StopIteration
            # when an iter throws it. So if the first iter throws it, the second
            # is *not* consumed. We rely on this, so don't change the order
            # without changing the logic.
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
        else:
            # Slower, kwargs-ready version.
            fields_iter = iter(opts.fields)
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
                if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
                    raise TypeError(
                        f"{cls.__qualname__}() got both positional and "
                        f"keyword arguments for field '{field.name}'."
                    )
    
        # Now we're left with the unprocessed fields that *must* come from
        # keywords, or default.
    
        for field in fields_iter:
            is_related_object = False
            # Virtual field
            if field.attname not in kwargs and field.column is None:
                continue
            if kwargs:
                if isinstance(field.remote_field, ForeignObjectRel):
                    try:
                        # Assume object instance was passed in.
                        rel_obj = kwargs.pop(field.name)
                        is_related_object = True
                    except KeyError:
                        try:
                            # Object instance wasn't passed in -- must be an ID.
                            val = kwargs.pop(field.attname)
                        except KeyError:
                            val = field.get_default()
                else:
                    try:
                        val = kwargs.pop(field.attname)
                    except KeyError:
                        # This is done with an exception rather than the
                        # default argument on pop because we don't want
                        # get_default() to be evaluated, and then not used.
                        # Refs #12057.
                        val = field.get_default()
            else:
                val = field.get_default()
    
            if is_related_object:
                # If we are passed a related instance, set it using the
                # field.name instead of field.attname (e.g. "user" instead of
                # "user_id") so that the object gets properly cached (and type
                # checked) by the RelatedObjectDescriptor.
                if rel_obj is not _DEFERRED:
                    _setattr(self, field.name, rel_obj)
            else:
                if val is not _DEFERRED:
                    _setattr(self, field.attname, val)
    
        if kwargs:
            property_names = opts._property_names
            unexpected = ()
            for prop, value in kwargs.items():
                # Any remaining kwargs must correspond to properties or virtual
                # fields.
                if prop in property_names:
                    if value is not _DEFERRED:
                        _setattr(self, prop, value)
                else:
                    try:
                        opts.get_field(prop)
                    except FieldDoesNotExist:
                        unexpected += (prop,)
                    else:
                        if value is not _DEFERRED:
                            _setattr(self, prop, value)
            if unexpected:
                unexpected_names = ", ".join(repr(n) for n in unexpected)
>               raise TypeError(
                    f"{cls.__name__}() got unexpected keyword arguments: "
                    f"{unexpected_names}"
                )
E               TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

.../local/lib/python3.12.../db/models/base.py:567: TypeError

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

@codecov-qa
Copy link

codecov-qa bot commented Sep 16, 2024

❌ 29 Tests Failed:

Tests completed Failed Passed Skipped
2297 29 2268 6
View the top 3 failed tests by shortest run time
graphql_api.tests.test_repository.TestFetchRepository test_desc_failure_rate_ordering_on_test_results
Stack Traces | 0.31s run time
self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_failure_rate_ordering_on_test_results>

    def test_desc_failure_rate_ordering_on_test_results(self) -> None:
        repo = RepositoryFactory(author=self.owner, active=True, private=True)
        test = TestFactory(repository=repo)
>       _ = DailyTestRollupFactory(
            test=test,
            date=datetime.date.today() - datetime.timedelta(days=1),
            repoid=repo.repoid,
            pass_count=1,
            fail_count=1,
        )

graphql_api/tests/test_repository.py:1229: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
.../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
.../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
.../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
.../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
.../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
.../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
kwargs = {'flaky_fail_count': 0}
cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
_DEFERRED = <Deferred field>
fields_iter = <tuple_iterator object at 0x7fdde4209360>
val = ['123', '456', '789']
field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
is_related_object = False, rel_obj = <Test: Test object (14)>
property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
        # Alias some things as locals to avoid repeat global lookups
        cls = self.__class__
        opts = self._meta
        _setattr = setattr
        _DEFERRED = DEFERRED
        if opts.abstract:
            raise TypeError("Abstract models cannot be instantiated.")
    
        pre_init.send(sender=cls, args=args, kwargs=kwargs)
    
        # Set up the storage for instance state
        self._state = ModelState()
    
        # There is a rather weird disparity here; if kwargs, it's set, then args
        # overrides it. It should be one or the other; don't duplicate the work
        # The reason for the kwargs check is that standard iterator passes in by
        # args, and instantiation for iteration is 33% faster.
        if len(args) > len(opts.concrete_fields):
            # Daft, but matches old exception sans the err msg.
            raise IndexError("Number of args exceeds number of fields")
    
        if not kwargs:
            fields_iter = iter(opts.concrete_fields)
            # The ordering of the zip calls matter - zip throws StopIteration
            # when an iter throws it. So if the first iter throws it, the second
            # is *not* consumed. We rely on this, so don't change the order
            # without changing the logic.
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
        else:
            # Slower, kwargs-ready version.
            fields_iter = iter(opts.fields)
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
                if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
                    raise TypeError(
                        f"{cls.__qualname__}() got both positional and "
                        f"keyword arguments for field '{field.name}'."
                    )
    
        # Now we're left with the unprocessed fields that *must* come from
        # keywords, or default.
    
        for field in fields_iter:
            is_related_object = False
            # Virtual field
            if field.attname not in kwargs and field.column is None:
                continue
            if kwargs:
                if isinstance(field.remote_field, ForeignObjectRel):
                    try:
                        # Assume object instance was passed in.
                        rel_obj = kwargs.pop(field.name)
                        is_related_object = True
                    except KeyError:
                        try:
                            # Object instance wasn't passed in -- must be an ID.
                            val = kwargs.pop(field.attname)
                        except KeyError:
                            val = field.get_default()
                else:
                    try:
                        val = kwargs.pop(field.attname)
                    except KeyError:
                        # This is done with an exception rather than the
                        # default argument on pop because we don't want
                        # get_default() to be evaluated, and then not used.
                        # Refs #12057.
                        val = field.get_default()
            else:
                val = field.get_default()
    
            if is_related_object:
                # If we are passed a related instance, set it using the
                # field.name instead of field.attname (e.g. "user" instead of
                # "user_id") so that the object gets properly cached (and type
                # checked) by the RelatedObjectDescriptor.
                if rel_obj is not _DEFERRED:
                    _setattr(self, field.name, rel_obj)
            else:
                if val is not _DEFERRED:
                    _setattr(self, field.attname, val)
    
        if kwargs:
            property_names = opts._property_names
            unexpected = ()
            for prop, value in kwargs.items():
                # Any remaining kwargs must correspond to properties or virtual
                # fields.
                if prop in property_names:
                    if value is not _DEFERRED:
                        _setattr(self, prop, value)
                else:
                    try:
                        opts.get_field(prop)
                    except FieldDoesNotExist:
                        unexpected += (prop,)
                    else:
                        if value is not _DEFERRED:
                            _setattr(self, prop, value)
            if unexpected:
                unexpected_names = ", ".join(repr(n) for n in unexpected)
>               raise TypeError(
                    f"{cls.__name__}() got unexpected keyword arguments: "
                    f"{unexpected_names}"
                )
E               TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

.../local/lib/python3.12.../db/models/base.py:567: TypeError
graphql_api.tests.test_repository.TestFetchRepository test_commits_failed_ordering_on_test_results
Stack Traces | 0.311s run time
self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_commits_failed_ordering_on_test_results>

    def test_commits_failed_ordering_on_test_results(self) -> None:
        repo = RepositoryFactory(author=self.owner, active=True, private=True)
        test = TestFactory(repository=repo)
>       _ = DailyTestRollupFactory(
            test=test,
            date=datetime.date.today() - datetime.timedelta(days=1),
            repoid=repo.repoid,
            commits_where_fail=["1"],
        )

graphql_api/tests/test_repository.py:989: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
.../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
.../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
.../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
.../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
.../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
.../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
kwargs = {'flaky_fail_count': 0}
cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
_DEFERRED = <Deferred field>
fields_iter = <tuple_iterator object at 0x7fdde4e2a530>, val = ['1']
field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
is_related_object = False, rel_obj = <Test: Test object (11)>
property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
        # Alias some things as locals to avoid repeat global lookups
        cls = self.__class__
        opts = self._meta
        _setattr = setattr
        _DEFERRED = DEFERRED
        if opts.abstract:
            raise TypeError("Abstract models cannot be instantiated.")
    
        pre_init.send(sender=cls, args=args, kwargs=kwargs)
    
        # Set up the storage for instance state
        self._state = ModelState()
    
        # There is a rather weird disparity here; if kwargs, it's set, then args
        # overrides it. It should be one or the other; don't duplicate the work
        # The reason for the kwargs check is that standard iterator passes in by
        # args, and instantiation for iteration is 33% faster.
        if len(args) > len(opts.concrete_fields):
            # Daft, but matches old exception sans the err msg.
            raise IndexError("Number of args exceeds number of fields")
    
        if not kwargs:
            fields_iter = iter(opts.concrete_fields)
            # The ordering of the zip calls matter - zip throws StopIteration
            # when an iter throws it. So if the first iter throws it, the second
            # is *not* consumed. We rely on this, so don't change the order
            # without changing the logic.
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
        else:
            # Slower, kwargs-ready version.
            fields_iter = iter(opts.fields)
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
                if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
                    raise TypeError(
                        f"{cls.__qualname__}() got both positional and "
                        f"keyword arguments for field '{field.name}'."
                    )
    
        # Now we're left with the unprocessed fields that *must* come from
        # keywords, or default.
    
        for field in fields_iter:
            is_related_object = False
            # Virtual field
            if field.attname not in kwargs and field.column is None:
                continue
            if kwargs:
                if isinstance(field.remote_field, ForeignObjectRel):
                    try:
                        # Assume object instance was passed in.
                        rel_obj = kwargs.pop(field.name)
                        is_related_object = True
                    except KeyError:
                        try:
                            # Object instance wasn't passed in -- must be an ID.
                            val = kwargs.pop(field.attname)
                        except KeyError:
                            val = field.get_default()
                else:
                    try:
                        val = kwargs.pop(field.attname)
                    except KeyError:
                        # This is done with an exception rather than the
                        # default argument on pop because we don't want
                        # get_default() to be evaluated, and then not used.
                        # Refs #12057.
                        val = field.get_default()
            else:
                val = field.get_default()
    
            if is_related_object:
                # If we are passed a related instance, set it using the
                # field.name instead of field.attname (e.g. "user" instead of
                # "user_id") so that the object gets properly cached (and type
                # checked) by the RelatedObjectDescriptor.
                if rel_obj is not _DEFERRED:
                    _setattr(self, field.name, rel_obj)
            else:
                if val is not _DEFERRED:
                    _setattr(self, field.attname, val)
    
        if kwargs:
            property_names = opts._property_names
            unexpected = ()
            for prop, value in kwargs.items():
                # Any remaining kwargs must correspond to properties or virtual
                # fields.
                if prop in property_names:
                    if value is not _DEFERRED:
                        _setattr(self, prop, value)
                else:
                    try:
                        opts.get_field(prop)
                    except FieldDoesNotExist:
                        unexpected += (prop,)
                    else:
                        if value is not _DEFERRED:
                            _setattr(self, prop, value)
            if unexpected:
                unexpected_names = ", ".join(repr(n) for n in unexpected)
>               raise TypeError(
                    f"{cls.__name__}() got unexpected keyword arguments: "
                    f"{unexpected_names}"
                )
E               TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

.../local/lib/python3.12.../db/models/base.py:567: TypeError
graphql_api.tests.test_repository.TestFetchRepository test_desc_avg_duration_ordering_on_test_results
Stack Traces | 0.313s run time
self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_avg_duration_ordering_on_test_results>

    def test_desc_avg_duration_ordering_on_test_results(self) -> None:
        repo = RepositoryFactory(author=self.owner, active=True, private=True)
        test = TestFactory(repository=repo)
>       _ = DailyTestRollupFactory(
            test=test,
            date=datetime.date.today() - datetime.timedelta(days=1),
            repoid=repo.repoid,
            avg_duration_seconds=1,
        )

graphql_api/tests/test_repository.py:1159: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
.../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
.../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
.../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
.../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
.../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
.../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
kwargs = {'flaky_fail_count': 0}
cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
_DEFERRED = <Deferred field>
fields_iter = <tuple_iterator object at 0x7fdde4520af0>
val = ['123', '456', '789']
field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
is_related_object = False, rel_obj = <Test: Test object (12)>
property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
        # Alias some things as locals to avoid repeat global lookups
        cls = self.__class__
        opts = self._meta
        _setattr = setattr
        _DEFERRED = DEFERRED
        if opts.abstract:
            raise TypeError("Abstract models cannot be instantiated.")
    
        pre_init.send(sender=cls, args=args, kwargs=kwargs)
    
        # Set up the storage for instance state
        self._state = ModelState()
    
        # There is a rather weird disparity here; if kwargs, it's set, then args
        # overrides it. It should be one or the other; don't duplicate the work
        # The reason for the kwargs check is that standard iterator passes in by
        # args, and instantiation for iteration is 33% faster.
        if len(args) > len(opts.concrete_fields):
            # Daft, but matches old exception sans the err msg.
            raise IndexError("Number of args exceeds number of fields")
    
        if not kwargs:
            fields_iter = iter(opts.concrete_fields)
            # The ordering of the zip calls matter - zip throws StopIteration
            # when an iter throws it. So if the first iter throws it, the second
            # is *not* consumed. We rely on this, so don't change the order
            # without changing the logic.
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
        else:
            # Slower, kwargs-ready version.
            fields_iter = iter(opts.fields)
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
                if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
                    raise TypeError(
                        f"{cls.__qualname__}() got both positional and "
                        f"keyword arguments for field '{field.name}'."
                    )
    
        # Now we're left with the unprocessed fields that *must* come from
        # keywords, or default.
    
        for field in fields_iter:
            is_related_object = False
            # Virtual field
            if field.attname not in kwargs and field.column is None:
                continue
            if kwargs:
                if isinstance(field.remote_field, ForeignObjectRel):
                    try:
                        # Assume object instance was passed in.
                        rel_obj = kwargs.pop(field.name)
                        is_related_object = True
                    except KeyError:
                        try:
                            # Object instance wasn't passed in -- must be an ID.
                            val = kwargs.pop(field.attname)
                        except KeyError:
                            val = field.get_default()
                else:
                    try:
                        val = kwargs.pop(field.attname)
                    except KeyError:
                        # This is done with an exception rather than the
                        # default argument on pop because we don't want
                        # get_default() to be evaluated, and then not used.
                        # Refs #12057.
                        val = field.get_default()
            else:
                val = field.get_default()
    
            if is_related_object:
                # If we are passed a related instance, set it using the
                # field.name instead of field.attname (e.g. "user" instead of
                # "user_id") so that the object gets properly cached (and type
                # checked) by the RelatedObjectDescriptor.
                if rel_obj is not _DEFERRED:
                    _setattr(self, field.name, rel_obj)
            else:
                if val is not _DEFERRED:
                    _setattr(self, field.attname, val)
    
        if kwargs:
            property_names = opts._property_names
            unexpected = ()
            for prop, value in kwargs.items():
                # Any remaining kwargs must correspond to properties or virtual
                # fields.
                if prop in property_names:
                    if value is not _DEFERRED:
                        _setattr(self, prop, value)
                else:
                    try:
                        opts.get_field(prop)
                    except FieldDoesNotExist:
                        unexpected += (prop,)
                    else:
                        if value is not _DEFERRED:
                            _setattr(self, prop, value)
            if unexpected:
                unexpected_names = ", ".join(repr(n) for n in unexpected)
>               raise TypeError(
                    f"{cls.__name__}() got unexpected keyword arguments: "
                    f"{unexpected_names}"
                )
E               TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

.../local/lib/python3.12.../db/models/base.py:567: TypeError

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Copy link

Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time.

❌ Failed Test Results:

Completed 2303 tests with 29 failed, 2268 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: graphql_api.tests.test_flake_aggregates.TestResultTestCase
    Test name: test_fetch_test_result_total_runtime

    self = <graphql_api.tests.test_flake_aggregates.TestResultTestCase testMethod=test_fetch_test_result_total_runtime>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(author=self.owner, branch="main")

    for i in range(0, 30):
    test = TestFactory(repository=self.repository)
    _ = FlakeFactory(
    repository=self.repository,
    test=test,
    end_date=datetime.now() - timedelta(days=i),
    )
    > _ = DailyTestRollupFactory(
    test=test,
    date=date.today() - timedelta(days=i),
    avg_duration_seconds=float(i),
    latest_run=datetime.now() - timedelta(days=i),
    fail_count=1,
    skip_count=1,
    pass_count=0,
    flaky_fail_count=1 if i % 5 == 0 else 0,
    branch="main",
    )

    graphql_api/tests/test_flake_aggregates.py:27:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 1}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fddd5cb8b80>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (6)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_avg_duration_ordering_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_avg_duration_ordering_on_test_results>

    def test_avg_duration_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    date=datetime.date.today() - datetime.timedelta(days=1),
    repoid=repo.repoid,
    avg_duration_seconds=1,
    )

    graphql_api/tests/test_repository.py:1126:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fddd5adb100>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (8)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_branch_filter_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_branch_filter_on_test_results>

    def test_branch_filter_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    test2 = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    created_at=datetime.datetime.now(),
    repoid=repo.repoid,
    branch="main",
    )

    graphql_api/tests/test_repository.py:897:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fde004db670>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (9)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_commits_failed_ordering_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_commits_failed_ordering_on_test_results>

    def test_commits_failed_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    date=datetime.date.today() - datetime.timedelta(days=1),
    repoid=repo.repoid,
    commits_where_fail=["1"],
    )

    graphql_api/tests/test_repository.py:989:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde4e2a530>, val = ['1']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (11)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_desc_avg_duration_ordering_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_avg_duration_ordering_on_test_results>

    def test_desc_avg_duration_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    date=datetime.date.today() - datetime.timedelta(days=1),
    repoid=repo.repoid,
    avg_duration_seconds=1,
    )

    graphql_api/tests/test_repository.py:1159:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde4520af0>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (12)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_desc_commits_failed_ordering_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_commits_failed_ordering_on_test_results>

    def test_desc_commits_failed_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    date=datetime.date.today() - datetime.timedelta(days=1),
    repoid=repo.repoid,
    commits_where_fail=["1"],
    )

    graphql_api/tests/test_repository.py:1022:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fde09ad0700>, val = ['1']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (13)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_desc_failure_rate_ordering_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_failure_rate_ordering_on_test_results>

    def test_desc_failure_rate_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    date=datetime.date.today() - datetime.timedelta(days=1),
    repoid=repo.repoid,
    pass_count=1,
    fail_count=1,
    )

    graphql_api/tests/test_repository.py:1229:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde4209360>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (14)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_desc_flake_rate_ordering_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_flake_rate_ordering_on_test_results>

    def test_desc_flake_rate_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    date=datetime.date.today() - datetime.timedelta(days=1),
    repoid=repo.repoid,
    pass_count=1,
    fail_count=1,
    flaky_fail_count=1,
    )

    graphql_api/tests/test_repository.py:1306:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 1}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fddd7ea65f0>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (15)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_desc_last_duration_ordering_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_last_duration_ordering_on_test_results>

    def test_desc_last_duration_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    date=datetime.date.today() - datetime.timedelta(days=1),
    repoid=repo.repoid,
    last_duration_seconds=1,
    latest_run=datetime.datetime.now() - datetime.timedelta(days=1),
    )

    graphql_api/tests/test_repository.py:1090:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde4894880>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (16)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_failed_filter_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_failed_filter_on_test_results>

    def test_failed_filter_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    test2 = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    created_at=datetime.datetime.now(),
    repoid=repo.repoid,
    branch="main",
    fail_count=0,
    )

    graphql_api/tests/test_repository.py:942:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde48865c0>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (17)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_failure_rate_ordering_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_failure_rate_ordering_on_test_results>

    def test_failure_rate_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    date=datetime.date.today() - datetime.timedelta(days=1),
    repoid=repo.repoid,
    pass_count=1,
    fail_count=1,
    )

    graphql_api/tests/test_repository.py:1192:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fde09cdab60>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (19)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_flake_rate_filtering_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_flake_rate_filtering_on_test_results>

    def test_flake_rate_filtering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    date=datetime.date.today() - datetime.timedelta(days=1),
    repoid=repo.repoid,
    pass_count=1,
    fail_count=1,
    flaky_fail_count=1,
    )

    graphql_api/tests/test_repository.py:1266:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 1}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fde004e02b0>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (20)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_flaky_filter_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_flaky_filter_on_test_results>

    def test_flaky_filter_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    test2 = TestFactory(repository=repo)
    _ = FlakeFactory(test=test2, repository=repo, end_date=None)
    > _ = DailyTestRollupFactory(
    test=test,
    created_at=datetime.datetime.now(),
    repoid=repo.repoid,
    branch="main",
    )

    graphql_api/tests/test_repository.py:920:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde48797b0>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (21)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_last_duration_ordering_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_last_duration_ordering_on_test_results>

    def test_last_duration_ordering_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    date=datetime.date.today() - datetime.timedelta(days=1),
    repoid=repo.repoid,
    last_duration_seconds=1,
    latest_run=datetime.datetime.now() - datetime.timedelta(days=1),
    )

    graphql_api/tests/test_repository.py:1055:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fde0a8de9e0>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (23)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_slowest_filter_on_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_slowest_filter_on_test_results>

    def test_slowest_filter_on_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)
    test2 = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    created_at=datetime.datetime.now(),
    repoid=repo.repoid,
    branch="main",
    avg_duration_seconds=0.1,
    )

    graphql_api/tests/test_repository.py:966:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fde028b2d10>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (24)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_test_results

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_test_results>

    def test_test_results(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    test = TestFactory(repository=repo)

    > _ = DailyTestRollupFactory(test=test)

    graphql_api/tests/test_repository.py:880:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fddf882bf70>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (26)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_test_results_aggregates

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_test_results_aggregates>

    def test_test_results_aggregates(self) -> None:
    repo = RepositoryFactory(
    author=self.owner, active=True, private=True, branch="main"
    )

    for i in range(0, 30):
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    repoid=repo.repoid,
    branch="main",
    fail_count=1 if i % 3 == 0 else 0,
    skip_count=1 if i % 6 == 0 else 0,
    pass_count=1,
    avg_duration_seconds=float(i),
    last_duration_seconds=float(i),
    date=datetime.date.today() - datetime.timedelta(days=i),
    )

    graphql_api/tests/test_repository.py:1350:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fddf82f0b80>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (27)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_test_results_aggregates_no_history

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_test_results_aggregates_no_history>

    def test_test_results_aggregates_no_history(self) -> None:
    repo = RepositoryFactory(
    author=self.owner, active=True, private=True, branch="main"
    )

    for i in range(0, 30):
    test = TestFactory(repository=repo)
    > _ = DailyTestRollupFactory(
    test=test,
    repoid=repo.repoid,
    branch="main",
    fail_count=1 if i % 3 == 0 else 0,
    skip_count=1 if i % 6 == 0 else 0,
    pass_count=1,
    avg_duration_seconds=float(i),
    last_duration_seconds=float(i),
    date=datetime.date.today() - datetime.timedelta(days=i),
    )

    graphql_api/tests/test_repository.py:1397:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fddf882bf70>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (28)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_repository.TestFetchRepository
    Test name: test_test_results_no_tests

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_test_results_no_tests>

    def test_test_results_no_tests(self) -> None:
    repo = RepositoryFactory(author=self.owner, active=True, private=True)
    > res = self.fetch_repository(
    repo.name, """testResults { edges { node { name } } }"""
    )

    graphql_api/tests/test_repository.py:888:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_repository.TestFetchRepository testMethod=test_test_results_no_tests>
    name = 'rest', fields = 'testResults { edges { node { name } } }'

    def fetch_repository(self, name, fields=None):
    data = self.gql_request(
    query_repository % (fields or default_fields),
    owner=self.owner,
    variables={"name": name},
    )
    > return data["me"]["owner"]["repository"]
    E TypeError: 'NoneType' object is not subscriptable

    graphql_api/tests/test_repository.py:90: TypeError
  • Class name: graphql_api.tests.test_test_result.TestResultTestCase
    Test name: test_fetch_test_result_avg_duration

    self = <graphql_api.tests.test_test_result.TestResultTestCase testMethod=test_fetch_test_result_avg_duration>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(
    author=self.owner,
    )
    self.test = TestFactory(
    name="Test\x1fName",
    repository=self.repository,
    )

    > _ = DailyTestRollupFactory(
    test=self.test,
    commits_where_fail=["123"],
    date=date.today() - timedelta(days=2),
    avg_duration_seconds=0.6,
    latest_run=datetime.now() - timedelta(days=2),
    )

    graphql_api/tests/test_test_result.py:25:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fde098f3850>, val = ['123']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (29)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_test_result.TestResultTestCase
    Test name: test_fetch_test_result_commits_failed

    self = <graphql_api.tests.test_test_result.TestResultTestCase testMethod=test_fetch_test_result_commits_failed>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(
    author=self.owner,
    )
    self.test = TestFactory(
    name="Test\x1fName",
    repository=self.repository,
    )

    > _ = DailyTestRollupFactory(
    test=self.test,
    commits_where_fail=["123"],
    date=date.today() - timedelta(days=2),
    avg_duration_seconds=0.6,
    latest_run=datetime.now() - timedelta(days=2),
    )

    graphql_api/tests/test_test_result.py:25:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fde09342fb0>, val = ['123']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (30)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_test_result.TestResultTestCase
    Test name: test_fetch_test_result_failure_rate

    self = <graphql_api.tests.test_test_result.TestResultTestCase testMethod=test_fetch_test_result_failure_rate>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(
    author=self.owner,
    )
    self.test = TestFactory(
    name="Test\x1fName",
    repository=self.repository,
    )

    > _ = DailyTestRollupFactory(
    test=self.test,
    commits_where_fail=["123"],
    date=date.today() - timedelta(days=2),
    avg_duration_seconds=0.6,
    latest_run=datetime.now() - timedelta(days=2),
    )

    graphql_api/tests/test_test_result.py:25:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde42e8b80>, val = ['123']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (31)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_test_result.TestResultTestCase
    Test name: test_fetch_test_result_last_duration

    self = <graphql_api.tests.test_test_result.TestResultTestCase testMethod=test_fetch_test_result_last_duration>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(
    author=self.owner,
    )
    self.test = TestFactory(
    name="Test\x1fName",
    repository=self.repository,
    )

    > _ = DailyTestRollupFactory(
    test=self.test,
    commits_where_fail=["123"],
    date=date.today() - timedelta(days=2),
    avg_duration_seconds=0.6,
    latest_run=datetime.now() - timedelta(days=2),
    )

    graphql_api/tests/test_test_result.py:25:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde42e8460>, val = ['123']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (32)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_test_result.TestResultTestCase
    Test name: test_fetch_test_result_name

    self = <graphql_api.tests.test_test_result.TestResultTestCase testMethod=test_fetch_test_result_name>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(
    author=self.owner,
    )
    self.test = TestFactory(
    name="Test\x1fName",
    repository=self.repository,
    )

    > _ = DailyTestRollupFactory(
    test=self.test,
    commits_where_fail=["123"],
    date=date.today() - timedelta(days=2),
    avg_duration_seconds=0.6,
    latest_run=datetime.now() - timedelta(days=2),
    )

    graphql_api/tests/test_test_result.py:25:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fde0986e5f0>, val = ['123']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (33)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_test_result.TestResultTestCase
    Test name: test_fetch_test_result_updated_at

    self = <graphql_api.tests.test_test_result.TestResultTestCase testMethod=test_fetch_test_result_updated_at>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(
    author=self.owner,
    )
    self.test = TestFactory(
    name="Test\x1fName",
    repository=self.repository,
    )

    > _ = DailyTestRollupFactory(
    test=self.test,
    commits_where_fail=["123"],
    date=date.today() - timedelta(days=2),
    avg_duration_seconds=0.6,
    latest_run=datetime.now() - timedelta(days=2),
    )

    graphql_api/tests/test_test_result.py:25:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde485d0f0>, val = ['123']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (34)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_test_results_headers.TestResultTestCase
    Test name: test_fetch_test_result_failed_tests

    self = <graphql_api.tests.test_test_results_headers.TestResultTestCase testMethod=test_fetch_test_result_failed_tests>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(author=self.owner, branch="main")

    for i in range(1, 31):
    test = TestFactory(repository=self.repository)

    > _ = DailyTestRollupFactory(
    test=test,
    date=date.today() - timedelta(days=i),
    avg_duration_seconds=float(i),
    latest_run=datetime.now() - timedelta(days=i),
    fail_count=1,
    skip_count=1,
    pass_count=0,
    branch="main",
    )

    graphql_api/tests/test_test_results_headers.py:22:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde455b3d0>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (35)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_test_results_headers.TestResultTestCase
    Test name: test_fetch_test_result_skipped_tests

    self = <graphql_api.tests.test_test_results_headers.TestResultTestCase testMethod=test_fetch_test_result_skipped_tests>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(author=self.owner, branch="main")

    for i in range(1, 31):
    test = TestFactory(repository=self.repository)

    > _ = DailyTestRollupFactory(
    test=test,
    date=date.today() - timedelta(days=i),
    avg_duration_seconds=float(i),
    latest_run=datetime.now() - timedelta(days=i),
    fail_count=1,
    skip_count=1,
    pass_count=0,
    branch="main",
    )

    graphql_api/tests/test_test_results_headers.py:22:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fddf8338220>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (36)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_test_results_headers.TestResultTestCase
    Test name: test_fetch_test_result_slowest_tests_runtime

    self = <graphql_api.tests.test_test_results_headers.TestResultTestCase testMethod=test_fetch_test_result_slowest_tests_runtime>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(author=self.owner, branch="main")

    for i in range(1, 31):
    test = TestFactory(repository=self.repository)

    > _ = DailyTestRollupFactory(
    test=test,
    date=date.today() - timedelta(days=i),
    avg_duration_seconds=float(i),
    latest_run=datetime.now() - timedelta(days=i),
    fail_count=1,
    skip_count=1,
    pass_count=0,
    branch="main",
    )

    graphql_api/tests/test_test_results_headers.py:22:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fdde48b9450>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (37)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError
  • Class name: graphql_api.tests.test_test_results_headers.TestResultTestCase
    Test name: test_fetch_test_result_total_runtime

    self = <graphql_api.tests.test_test_results_headers.TestResultTestCase testMethod=test_fetch_test_result_total_runtime>

    def setUp(self):
    self.owner = OwnerFactory(username="randomOwner")
    self.repository = RepositoryFactory(author=self.owner, branch="main")

    for i in range(1, 31):
    test = TestFactory(repository=self.repository)

    > _ = DailyTestRollupFactory(
    test=test,
    date=date.today() - timedelta(days=i),
    avg_duration_seconds=float(i),
    latest_run=datetime.now() - timedelta(days=i),
    fail_count=1,
    skip_count=1,
    pass_count=0,
    branch="main",
    )

    graphql_api/tests/test_test_results_headers.py:22:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
    .../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
    .../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
    .../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
    .../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
    .../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    .../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <DailyTestRollup: DailyTestRollup object (None)>, args = ()
    kwargs = {'flaky_fail_count': 0}
    cls = <class 'shared.django_apps.reports.models.DailyTestRollup'>
    opts = <Options for DailyTestRollup>, _setattr = <built-in function setattr>
    _DEFERRED = <Deferred field>
    fields_iter = <tuple_iterator object at 0x7fde00214f10>
    val = ['123', '456', '789']
    field = <django.contrib.postgres.fields.array.ArrayField: commits_where_fail>
    is_related_object = False, rel_obj = <Test: Test object (38)>
    property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
    # Alias some things as locals to avoid repeat global lookups
    cls = self.__class__
    opts = self._meta
    _setattr = setattr
    _DEFERRED = DEFERRED
    if opts.abstract:
    raise TypeError("Abstract models cannot be instantiated.")

    pre_init.send(sender=cls, args=args, kwargs=kwargs)

    # Set up the storage for instance state
    self._state = ModelState()

    # There is a rather weird disparity here; if kwargs, it's set, then args
    # overrides it. It should be one or the other; don't duplicate the work
    # The reason for the kwargs check is that standard iterator passes in by
    # args, and instantiation for iteration is 33% faster.
    if len(args) > len(opts.concrete_fields):
    # Daft, but matches old exception sans the err msg.
    raise IndexError("Number of args exceeds number of fields")

    if not kwargs:
    fields_iter = iter(opts.concrete_fields)
    # The ordering of the zip calls matter - zip throws StopIteration
    # when an iter throws it. So if the first iter throws it, the second
    # is *not* consumed. We rely on this, so don't change the order
    # without changing the logic.
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    else:
    # Slower, kwargs-ready version.
    fields_iter = iter(opts.fields)
    for val, field in zip(args, fields_iter):
    if val is _DEFERRED:
    continue
    _setattr(self, field.attname, val)
    if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
    raise TypeError(
    f"{cls.__qualname__}() got both positional and "
    f"keyword arguments for field '{field.name}'."
    )

    # Now we're left with the unprocessed fields that *must* come from
    # keywords, or default.

    for field in fields_iter:
    is_related_object = False
    # Virtual field
    if field.attname not in kwargs and field.column is None:
    continue
    if kwargs:
    if isinstance(field.remote_field, ForeignObjectRel):
    try:
    # Assume object instance was passed in.
    rel_obj = kwargs.pop(field.name)
    is_related_object = True
    except KeyError:
    try:
    # Object instance wasn't passed in -- must be an ID.
    val = kwargs.pop(field.attname)
    except KeyError:
    val = field.get_default()
    else:
    try:
    val = kwargs.pop(field.attname)
    except KeyError:
    # This is done with an exception rather than the
    # default argument on pop because we don't want
    # get_default() to be evaluated, and then not used.
    # Refs #12057.
    val = field.get_default()
    else:
    val = field.get_default()

    if is_related_object:
    # If we are passed a related instance, set it using the
    # field.name instead of field.attname (e.g. "user" instead of
    # "user_id") so that the object gets properly cached (and type
    # checked) by the RelatedObjectDescriptor.
    if rel_obj is not _DEFERRED:
    _setattr(self, field.name, rel_obj)
    else:
    if val is not _DEFERRED:
    _setattr(self, field.attname, val)

    if kwargs:
    property_names = opts._property_names
    unexpected = ()
    for prop, value in kwargs.items():
    # Any remaining kwargs must correspond to properties or virtual
    # fields.
    if prop in property_names:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    else:
    try:
    opts.get_field(prop)
    except FieldDoesNotExist:
    unexpected += (prop,)
    else:
    if value is not _DEFERRED:
    _setattr(self, prop, value)
    if unexpected:
    unexpected_names = ", ".join(repr(n) for n in unexpected)
    > raise TypeError(
    f"{cls.__name__}() got unexpected keyword arguments: "
    f"{unexpected_names}"
    )
    E TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

    .../local/lib/python3.12.../db/models/base.py:567: TypeError

Copy link

codecov bot commented Sep 16, 2024

❌ 29 Tests Failed:

Tests completed Failed Passed Skipped
2297 29 2268 6
View the top 3 failed tests by shortest run time
graphql_api.tests.test_repository.TestFetchRepository test_desc_failure_rate_ordering_on_test_results
Stack Traces | 0.31s run time
self = &lt;graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_failure_rate_ordering_on_test_results&gt;

    def test_desc_failure_rate_ordering_on_test_results(self) -&gt; None:
        repo = RepositoryFactory(author=self.owner, active=True, private=True)
        test = TestFactory(repository=repo)
&gt;       _ = DailyTestRollupFactory(
            test=test,
            date=datetime.date.today() - datetime.timedelta(days=1),
            repoid=repo.repoid,
            pass_count=1,
            fail_count=1,
        )

graphql_api/tests/test_repository.py:1229: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
.../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
.../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
.../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
.../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
.../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
.../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;DailyTestRollup: DailyTestRollup object (None)&gt;, args = ()
kwargs = {'flaky_fail_count': 0}
cls = &lt;class 'shared.django_apps.reports.models.DailyTestRollup'&gt;
opts = &lt;Options for DailyTestRollup&gt;, _setattr = &lt;built-in function setattr&gt;
_DEFERRED = &lt;Deferred field&gt;
fields_iter = &lt;tuple_iterator object at 0x7fdde4209360&gt;
val = ['123', '456', '789']
field = &lt;django.contrib.postgres.fields.array.ArrayField: commits_where_fail&gt;
is_related_object = False, rel_obj = &lt;Test: Test object (14)&gt;
property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
        # Alias some things as locals to avoid repeat global lookups
        cls = self.__class__
        opts = self._meta
        _setattr = setattr
        _DEFERRED = DEFERRED
        if opts.abstract:
            raise TypeError("Abstract models cannot be instantiated.")
    
        pre_init.send(sender=cls, args=args, kwargs=kwargs)
    
        # Set up the storage for instance state
        self._state = ModelState()
    
        # There is a rather weird disparity here; if kwargs, it's set, then args
        # overrides it. It should be one or the other; don't duplicate the work
        # The reason for the kwargs check is that standard iterator passes in by
        # args, and instantiation for iteration is 33% faster.
        if len(args) &gt; len(opts.concrete_fields):
            # Daft, but matches old exception sans the err msg.
            raise IndexError("Number of args exceeds number of fields")
    
        if not kwargs:
            fields_iter = iter(opts.concrete_fields)
            # The ordering of the zip calls matter - zip throws StopIteration
            # when an iter throws it. So if the first iter throws it, the second
            # is *not* consumed. We rely on this, so don't change the order
            # without changing the logic.
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
        else:
            # Slower, kwargs-ready version.
            fields_iter = iter(opts.fields)
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
                if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
                    raise TypeError(
                        f"{cls.__qualname__}() got both positional and "
                        f"keyword arguments for field '{field.name}'."
                    )
    
        # Now we're left with the unprocessed fields that *must* come from
        # keywords, or default.
    
        for field in fields_iter:
            is_related_object = False
            # Virtual field
            if field.attname not in kwargs and field.column is None:
                continue
            if kwargs:
                if isinstance(field.remote_field, ForeignObjectRel):
                    try:
                        # Assume object instance was passed in.
                        rel_obj = kwargs.pop(field.name)
                        is_related_object = True
                    except KeyError:
                        try:
                            # Object instance wasn't passed in -- must be an ID.
                            val = kwargs.pop(field.attname)
                        except KeyError:
                            val = field.get_default()
                else:
                    try:
                        val = kwargs.pop(field.attname)
                    except KeyError:
                        # This is done with an exception rather than the
                        # default argument on pop because we don't want
                        # get_default() to be evaluated, and then not used.
                        # Refs #12057.
                        val = field.get_default()
            else:
                val = field.get_default()
    
            if is_related_object:
                # If we are passed a related instance, set it using the
                # field.name instead of field.attname (e.g. "user" instead of
                # "user_id") so that the object gets properly cached (and type
                # checked) by the RelatedObjectDescriptor.
                if rel_obj is not _DEFERRED:
                    _setattr(self, field.name, rel_obj)
            else:
                if val is not _DEFERRED:
                    _setattr(self, field.attname, val)
    
        if kwargs:
            property_names = opts._property_names
            unexpected = ()
            for prop, value in kwargs.items():
                # Any remaining kwargs must correspond to properties or virtual
                # fields.
                if prop in property_names:
                    if value is not _DEFERRED:
                        _setattr(self, prop, value)
                else:
                    try:
                        opts.get_field(prop)
                    except FieldDoesNotExist:
                        unexpected += (prop,)
                    else:
                        if value is not _DEFERRED:
                            _setattr(self, prop, value)
            if unexpected:
                unexpected_names = ", ".join(repr(n) for n in unexpected)
&gt;               raise TypeError(
                    f"{cls.__name__}() got unexpected keyword arguments: "
                    f"{unexpected_names}"
                )
E               TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

.../local/lib/python3.12.../db/models/base.py:567: TypeError
graphql_api.tests.test_repository.TestFetchRepository test_commits_failed_ordering_on_test_results
Stack Traces | 0.311s run time
self = &lt;graphql_api.tests.test_repository.TestFetchRepository testMethod=test_commits_failed_ordering_on_test_results&gt;

    def test_commits_failed_ordering_on_test_results(self) -&gt; None:
        repo = RepositoryFactory(author=self.owner, active=True, private=True)
        test = TestFactory(repository=repo)
&gt;       _ = DailyTestRollupFactory(
            test=test,
            date=datetime.date.today() - datetime.timedelta(days=1),
            repoid=repo.repoid,
            commits_where_fail=["1"],
        )

graphql_api/tests/test_repository.py:989: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
.../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
.../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
.../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
.../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
.../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
.../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;DailyTestRollup: DailyTestRollup object (None)&gt;, args = ()
kwargs = {'flaky_fail_count': 0}
cls = &lt;class 'shared.django_apps.reports.models.DailyTestRollup'&gt;
opts = &lt;Options for DailyTestRollup&gt;, _setattr = &lt;built-in function setattr&gt;
_DEFERRED = &lt;Deferred field&gt;
fields_iter = &lt;tuple_iterator object at 0x7fdde4e2a530&gt;, val = ['1']
field = &lt;django.contrib.postgres.fields.array.ArrayField: commits_where_fail&gt;
is_related_object = False, rel_obj = &lt;Test: Test object (11)&gt;
property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
        # Alias some things as locals to avoid repeat global lookups
        cls = self.__class__
        opts = self._meta
        _setattr = setattr
        _DEFERRED = DEFERRED
        if opts.abstract:
            raise TypeError("Abstract models cannot be instantiated.")
    
        pre_init.send(sender=cls, args=args, kwargs=kwargs)
    
        # Set up the storage for instance state
        self._state = ModelState()
    
        # There is a rather weird disparity here; if kwargs, it's set, then args
        # overrides it. It should be one or the other; don't duplicate the work
        # The reason for the kwargs check is that standard iterator passes in by
        # args, and instantiation for iteration is 33% faster.
        if len(args) &gt; len(opts.concrete_fields):
            # Daft, but matches old exception sans the err msg.
            raise IndexError("Number of args exceeds number of fields")
    
        if not kwargs:
            fields_iter = iter(opts.concrete_fields)
            # The ordering of the zip calls matter - zip throws StopIteration
            # when an iter throws it. So if the first iter throws it, the second
            # is *not* consumed. We rely on this, so don't change the order
            # without changing the logic.
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
        else:
            # Slower, kwargs-ready version.
            fields_iter = iter(opts.fields)
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
                if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
                    raise TypeError(
                        f"{cls.__qualname__}() got both positional and "
                        f"keyword arguments for field '{field.name}'."
                    )
    
        # Now we're left with the unprocessed fields that *must* come from
        # keywords, or default.
    
        for field in fields_iter:
            is_related_object = False
            # Virtual field
            if field.attname not in kwargs and field.column is None:
                continue
            if kwargs:
                if isinstance(field.remote_field, ForeignObjectRel):
                    try:
                        # Assume object instance was passed in.
                        rel_obj = kwargs.pop(field.name)
                        is_related_object = True
                    except KeyError:
                        try:
                            # Object instance wasn't passed in -- must be an ID.
                            val = kwargs.pop(field.attname)
                        except KeyError:
                            val = field.get_default()
                else:
                    try:
                        val = kwargs.pop(field.attname)
                    except KeyError:
                        # This is done with an exception rather than the
                        # default argument on pop because we don't want
                        # get_default() to be evaluated, and then not used.
                        # Refs #12057.
                        val = field.get_default()
            else:
                val = field.get_default()
    
            if is_related_object:
                # If we are passed a related instance, set it using the
                # field.name instead of field.attname (e.g. "user" instead of
                # "user_id") so that the object gets properly cached (and type
                # checked) by the RelatedObjectDescriptor.
                if rel_obj is not _DEFERRED:
                    _setattr(self, field.name, rel_obj)
            else:
                if val is not _DEFERRED:
                    _setattr(self, field.attname, val)
    
        if kwargs:
            property_names = opts._property_names
            unexpected = ()
            for prop, value in kwargs.items():
                # Any remaining kwargs must correspond to properties or virtual
                # fields.
                if prop in property_names:
                    if value is not _DEFERRED:
                        _setattr(self, prop, value)
                else:
                    try:
                        opts.get_field(prop)
                    except FieldDoesNotExist:
                        unexpected += (prop,)
                    else:
                        if value is not _DEFERRED:
                            _setattr(self, prop, value)
            if unexpected:
                unexpected_names = ", ".join(repr(n) for n in unexpected)
&gt;               raise TypeError(
                    f"{cls.__name__}() got unexpected keyword arguments: "
                    f"{unexpected_names}"
                )
E               TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

.../local/lib/python3.12.../db/models/base.py:567: TypeError
graphql_api.tests.test_repository.TestFetchRepository test_desc_avg_duration_ordering_on_test_results
Stack Traces | 0.313s run time
self = &lt;graphql_api.tests.test_repository.TestFetchRepository testMethod=test_desc_avg_duration_ordering_on_test_results&gt;

    def test_desc_avg_duration_ordering_on_test_results(self) -&gt; None:
        repo = RepositoryFactory(author=self.owner, active=True, private=True)
        test = TestFactory(repository=repo)
&gt;       _ = DailyTestRollupFactory(
            test=test,
            date=datetime.date.today() - datetime.timedelta(days=1),
            repoid=repo.repoid,
            avg_duration_seconds=1,
        )

graphql_api/tests/test_repository.py:1159: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/factory/base.py:40: in __call__
    return cls.create(**kwargs)
.../local/lib/python3.12............/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:117: in _generate
    return super()._generate(strategy, params)
.../local/lib/python3.12............/site-packages/factory/base.py:465: in _generate
    return step.build()
.../local/lib/python3.12.../site-packages/factory/builder.py:262: in build
    instance = self.factory_meta.instantiate(
.../local/lib/python3.12............/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
.../local/lib/python3.12....../site-packages/factory/django.py:166: in _create
    return manager.create(*args, **kwargs)
.../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
.../local/lib/python3.12.../db/models/query.py:656: in create
    obj = self.model(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;DailyTestRollup: DailyTestRollup object (None)&gt;, args = ()
kwargs = {'flaky_fail_count': 0}
cls = &lt;class 'shared.django_apps.reports.models.DailyTestRollup'&gt;
opts = &lt;Options for DailyTestRollup&gt;, _setattr = &lt;built-in function setattr&gt;
_DEFERRED = &lt;Deferred field&gt;
fields_iter = &lt;tuple_iterator object at 0x7fdde4520af0&gt;
val = ['123', '456', '789']
field = &lt;django.contrib.postgres.fields.array.ArrayField: commits_where_fail&gt;
is_related_object = False, rel_obj = &lt;Test: Test object (12)&gt;
property_names = frozenset({'pk'})

    def __init__(self, *args, **kwargs):
        # Alias some things as locals to avoid repeat global lookups
        cls = self.__class__
        opts = self._meta
        _setattr = setattr
        _DEFERRED = DEFERRED
        if opts.abstract:
            raise TypeError("Abstract models cannot be instantiated.")
    
        pre_init.send(sender=cls, args=args, kwargs=kwargs)
    
        # Set up the storage for instance state
        self._state = ModelState()
    
        # There is a rather weird disparity here; if kwargs, it's set, then args
        # overrides it. It should be one or the other; don't duplicate the work
        # The reason for the kwargs check is that standard iterator passes in by
        # args, and instantiation for iteration is 33% faster.
        if len(args) &gt; len(opts.concrete_fields):
            # Daft, but matches old exception sans the err msg.
            raise IndexError("Number of args exceeds number of fields")
    
        if not kwargs:
            fields_iter = iter(opts.concrete_fields)
            # The ordering of the zip calls matter - zip throws StopIteration
            # when an iter throws it. So if the first iter throws it, the second
            # is *not* consumed. We rely on this, so don't change the order
            # without changing the logic.
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
        else:
            # Slower, kwargs-ready version.
            fields_iter = iter(opts.fields)
            for val, field in zip(args, fields_iter):
                if val is _DEFERRED:
                    continue
                _setattr(self, field.attname, val)
                if kwargs.pop(field.name, NOT_PROVIDED) is not NOT_PROVIDED:
                    raise TypeError(
                        f"{cls.__qualname__}() got both positional and "
                        f"keyword arguments for field '{field.name}'."
                    )
    
        # Now we're left with the unprocessed fields that *must* come from
        # keywords, or default.
    
        for field in fields_iter:
            is_related_object = False
            # Virtual field
            if field.attname not in kwargs and field.column is None:
                continue
            if kwargs:
                if isinstance(field.remote_field, ForeignObjectRel):
                    try:
                        # Assume object instance was passed in.
                        rel_obj = kwargs.pop(field.name)
                        is_related_object = True
                    except KeyError:
                        try:
                            # Object instance wasn't passed in -- must be an ID.
                            val = kwargs.pop(field.attname)
                        except KeyError:
                            val = field.get_default()
                else:
                    try:
                        val = kwargs.pop(field.attname)
                    except KeyError:
                        # This is done with an exception rather than the
                        # default argument on pop because we don't want
                        # get_default() to be evaluated, and then not used.
                        # Refs #12057.
                        val = field.get_default()
            else:
                val = field.get_default()
    
            if is_related_object:
                # If we are passed a related instance, set it using the
                # field.name instead of field.attname (e.g. "user" instead of
                # "user_id") so that the object gets properly cached (and type
                # checked) by the RelatedObjectDescriptor.
                if rel_obj is not _DEFERRED:
                    _setattr(self, field.name, rel_obj)
            else:
                if val is not _DEFERRED:
                    _setattr(self, field.attname, val)
    
        if kwargs:
            property_names = opts._property_names
            unexpected = ()
            for prop, value in kwargs.items():
                # Any remaining kwargs must correspond to properties or virtual
                # fields.
                if prop in property_names:
                    if value is not _DEFERRED:
                        _setattr(self, prop, value)
                else:
                    try:
                        opts.get_field(prop)
                    except FieldDoesNotExist:
                        unexpected += (prop,)
                    else:
                        if value is not _DEFERRED:
                            _setattr(self, prop, value)
            if unexpected:
                unexpected_names = ", ".join(repr(n) for n in unexpected)
&gt;               raise TypeError(
                    f"{cls.__name__}() got unexpected keyword arguments: "
                    f"{unexpected_names}"
                )
E               TypeError: DailyTestRollup() got unexpected keyword arguments: 'flaky_fail_count'

.../local/lib/python3.12.../db/models/base.py:567: TypeError

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard


flake_aggregates = ariadne_load_local_graphql(__file__, "flake_aggregates.graphql")

__all__ = ["get_current_license", "flake_aggregates_bindable"]
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need get_current_license here?

__file__, "test_results_aggregates.graphql"
)

__all__ = ["get_current_license", "test_results_aggregates_bindable"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar story with if we need get_current_license

return obj["flake_rate"]


@flake_aggregates_bindable.field("flakeCountPercentChange")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: would personally organize these in "bunches" like flakeCount together and then flakeRate together vs. all the counts and all the %'s

I could see either approach tho



@flake_aggregates_bindable.field("flakeRatePercentChange")
def resolve_flake_rate_percent_change(obj, _) -> float | None:
Copy link
Contributor

Choose a reason for hiding this comment

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

in what situation would we return None for these? Vs. returning 0

repository: Repository,
info: GraphQLResolveInfo,
):
queryset = await sync_to_async(generate_test_results_aggregates)(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you just do a return await here for both of these resolvers?

@@ -25,6 +25,16 @@ def resolve_failure_rate(test, info) -> float | None:
return test["failure_rate"]


@test_result_bindable.field("flakeRate")
def resolve_flake_rate(test, info) -> float | None:
Copy link
Contributor

Choose a reason for hiding this comment

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

when would we want these to return None vs. 0?


@test_results_aggregates_bindable.field("slowestTestsRunTimePercentChange")
def resolve_slowest_tests_run_time_percent_change(obj, _) -> float | None:
return obj.get("slowest_tests_duration_percent_change")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: why is this called duration vs. runTime like the other? and to make resolver name



@test_results_aggregates_bindable.field("totalRunTimePercentChange")
def resolve_run_time_percent_change(obj, _) -> float | None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly when would these be None vs. 0?

commits_where_fail: list[str] | None
average_duration: float | None
def slow_test_threshold(num_tests: int):
threshold = floor(num_tests * (100 - SLOW_TEST_PERCENTILE) * 0.01)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: / 100 is a little easier to understand what we're doing here vs. * .01

def slow_test_threshold(num_tests: int):
threshold = floor(num_tests * (100 - SLOW_TEST_PERCENTILE) * 0.01)
if threshold == 0:
if num_tests < (1 / ((100 - SLOW_TEST_PERCENTILE) * 0.01)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this line needed? When would this statement be false if we're taking the floor already on line 30

repoid: int,
branch: str | None = None,
history: dt.timedelta | None = None,
parameter: GENERATE_TEST_RESULT_PARAM | None = None,
) -> QuerySet:
"""
Function that retrieves aggregated information about all tests in a given repository, for a given time range, optionally filtered by branch name.
The fields it calculates are: the test failure rate, commits where this test failed, and average duration of the test.
Copy link
Contributor

Choose a reason for hiding this comment

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

as well as last duration, flake rate, etc

branch=branch
)
totals = totals.filter(branch=branch)
print(parameter)
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder prints

test_ids = [flake.test_id for flake in flakes]

totals = totals.filter(test_id__in=test_ids)
case GENERATE_TEST_RESULT_PARAM.FAILED:
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: do cases in python automatically have break statements built in?



def percent_diff(a: int | float, b: int | float) -> int | float:
c = (a - b) / b * 100
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: just return this instead of doing variable assignment

) -> dict[str, int | float]:
diff_dict = {}

for s in ls:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: list comprehension

) -> dict[str, float | int] | None:
repo = Repository.objects.get(repoid=repoid)
time_ago = (
(dt.datetime.now(dt.UTC) - history) if history is not None else thirty_days_ago
Copy link
Contributor

Choose a reason for hiding this comment

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

we can simplify these if else's a bit if we set History to be a const dependent on it's value being passed in OR dt.timedelta(days=30)

so then we can just do time_ago = (
(dt.datetime.now(dt.UTC) - history) and double_time_ago = time_ago -
history

WIth something like history = history or dt.timedelta(days=30)

test_rollups = test_rollups.filter(date__lte=until.date())

if len(test_rollups) == 0:
assert 0 == 2
Copy link
Contributor

Choose a reason for hiding this comment

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

reminder remove assert

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.

2 participants