Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
another-rex committed Aug 9, 2024
1 parent 961e4fc commit 2b0c189
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
18 changes: 9 additions & 9 deletions gcp/appengine/frontend_handlers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ def test_ecosystem_counts(self):
self.assertDictEqual({'Debian': 2, 'PyPI': 1}, counts)


if __name__ == '__main__':
ds_emulator = tests.start_datastore_emulator()
try:
with ndb.Client().context() as context:
context.set_memcache_policy(False)
context.set_cache_policy(False)
unittest.main()
finally:
ds_emulator.kill()
# if __name__ == '__main__':
# ds_emulator = tests.start_datastore_emulator()
# try:
# with ndb.Client().context() as context:
# context.set_memcache_policy(False)
# context.set_cache_policy(False)
# unittest.main()
# finally:
# ds_emulator.kill()
15 changes: 7 additions & 8 deletions osv/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,22 @@ def start_datastore_emulator():
return proc


emulator_stdout_thread_output = ''


def _wait_for_emulator_ready(proc,
emulator,
indicator,
timeout=_EMULATOR_TIMEOUT):
"""Waits for emulator to be ready."""
global emulator_stdout_thread_output
emulator_stdout_thread_output = ''

def _read_thread(proc, ready_event):
"""Thread to continuously read from the process stdout."""
global emulator_stdout_thread_output
ready = False
while True:
line = proc.stdout.readline()
print(line)
if not line:
break
emulator_stdout_thread_output += str(line) + '\n'

print(line)
if not ready and indicator in line:
ready = True
ready_event.set()
Expand All @@ -162,7 +157,11 @@ def _read_thread(proc, ready_event):
if not ready_event.wait(timeout):
raise RuntimeError(
'{} emulator did not get ready in time.'.format(emulator))


# another_event = threading.Event()
# another_event.wait(5)
# raise RuntimeError(
# 'foisefjosdfji')
return thread


Expand Down

0 comments on commit 2b0c189

Please sign in to comment.