Cirq icon indicating copy to clipboard operation
Cirq copied to clipboard

Flaking engine_client_test

Open dabacon opened this issue 3 years ago • 3 comments

Lately I've been getting a flake on cirq-google/cirq_google/engine/engine_client_test.py

It has the strange behavior that a different number of the tests in this file fail.

Here is a typical failure

_____________________________ test_get_reservation _____________________________
[gw13] linux -- Python 3.9.12 /usr/local/google/home/dabacon/.virtualenvs/cirq-py3/bin/python

args = (), keywargs = {}

    @wraps(func)
    def patched(*args, **keywargs):
>       with self.decoration_helper(patched,
                                    args,
                                    keywargs) as (newargs, newkeywargs):

/usr/lib/python3.9/unittest/mock.py:1333: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.9/contextlib.py:119: in __enter__
    return next(self.gen)
/usr/lib/python3.9/unittest/mock.py:1315: in decoration_helper
    arg = exit_stack.enter_context(patching)
/usr/lib/python3.9/contextlib.py:448: in enter_context
    result = _cm_type.__enter__(cm)
/usr/lib/python3.9/unittest/mock.py:1488: in __enter__
    new = create_autospec(autospec, spec_set=spec_set,
/usr/lib/python3.9/unittest/mock.py:2687: in create_autospec
    _check_signature(original, new, skipfirst=skipfirst)
/usr/lib/python3.9/unittest/mock.py:120: in _check_signature
    _copy_func_details(func, checksig)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

func = <AsyncMock name='QuantumEngineServiceAsyncClient.cancel_quantum_job' spec='function' id='140304880977472'>
funcopy = <function _check_signature.<locals>.checksig at 0x7f9a6edbf3a0>

    def _copy_func_details(func, funcopy):
        # we explicitly don't copy func.__dict__ into this copy as it would
        # expose original attributes that should be mocked
        for attribute in (
            '__name__', '__doc__', '__text_signature__',
            '__module__', '__defaults__', '__kwdefaults__',
        ):
            try:
>               setattr(funcopy, attribute, getattr(func, attribute))
E               TypeError: __name__ must be set to a string object

/usr/lib/python3.9/unittest/mock.py:133: TypeError

dabacon avatar Jun 27 '22 22:06 dabacon

@maffoo @dstrain115 any idea what might be causing this, it looks to be coming from AsyncMock.

dabacon avatar Jun 28 '22 20:06 dabacon

I have not been able to reproduce the flakiness on either python 3.8.8 or python 3.9.13. How are you invoking pytest? I tried just running the cirq_google/engine/engine_client_test.py tests and also all tests in cirq_google/engine.

maffoo avatar Jun 28 '22 22:06 maffoo

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days

github-actions[bot] avatar Aug 06 '22 00:08 github-actions[bot]

Issue closed due to inactivity.

github-actions[bot] avatar Sep 05 '22 00:09 github-actions[bot]