uber/doubles

Doubling a constructor leaks to other test file

Closed this issue · 2 comments

I have following test in a file, which worked fine

def test_valid_message_checkr(self):
 """Test lock works and locked message is not submitted"""

allow(module).is_enabled_city.and_return(False)

consumer = InstanceDouble('bgc.lib.kafka.Consumer')
with no_builtin_verification():
  allow(module.Consumer).__new__.and_return(consumer)

  allow(consumer).get_envelopes.and_return(
      [ujson.dumps(self.kafka_bgc_log)],
  )

  allow(consumer).lock_message.and_return(False)

  expect(application).submit.never()

  module.main()

Somehow this results in totally unrelated failure in other file

_______________________________________________________ TestConsumer.test_get_envelopes _______________________________________________________
Traceback (most recent call last):

File "/home/uber/background-check/env/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
return func(*args, **keywargs)
File "/home/uber/background-check/bgc/tests/lib/kafka/kafka_consumer_test.py", line 26, in   test_get_envelopes
consumer = Consumer('background-check.submit', 42)
DeprecationWarning: object.new() takes no parameters

@rajeshucsb what version are you using?

Mocking of new requires doubles to do a little bit of strange stuff, so I can see this happening. I will take a look.

It was on 1.0.4