Skip to content

Commit

Permalink
Updated lc tests to async
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin-aguiar committed Oct 24, 2022
1 parent e5bde46 commit 3c6471c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
addopts = --capture=no --assert=plain --strict --tb native
testpaths = tests
asyncio_mode = auto
4 changes: 0 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[tool:pytest]
addopts = --capture=no --assert=plain --strict --tb native
testpaths = tests

[mypy]
python_version = 3.6
check_untyped_defs = True
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"flake8~=4.0.1",
"mypy",
"pytest",
"pytest-asyncio",
"requests==2.*",
"coverage",
"pytest-sugar",
Expand Down
16 changes: 8 additions & 8 deletions tests/endtoend/test_linux_consumption.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def setUpClass(cls):
raise RuntimeError('Environment variable AzureWebJobsStorage is '
'required before running Linux Consumption test')

def test_placeholder_mode_root_returns_ok(self):
async def test_placeholder_mode_root_returns_ok(self):
"""In any circumstances, a placeholder container should returns 200
even when it is not specialized.
"""
Expand All @@ -48,7 +48,7 @@ def test_placeholder_mode_root_returns_ok(self):
resp = ctrl.send_request(req)
self.assertTrue(resp.ok)

def test_http_no_auth(self):
async def test_http_no_auth(self):
"""An HttpTrigger function app with 'azure-functions' library
should return 200.
"""
Expand All @@ -62,7 +62,7 @@ def test_http_no_auth(self):
resp = ctrl.send_request(req)
self.assertEqual(resp.status_code, 200)

def test_common_libraries(self):
async def test_common_libraries(self):
"""A function app with the following requirements.txt:
azure-functions
Expand Down Expand Up @@ -92,7 +92,7 @@ def test_common_libraries(self):
self.assertIn('pyodbc', content)
self.assertIn('requests', content)

def test_new_protobuf(self):
async def test_new_protobuf(self):
"""A function app with the following requirements.txt:
azure-functions==1.7.0
Expand All @@ -119,7 +119,7 @@ def test_new_protobuf(self):
self.assertEqual(content['google.protobuf'], '3.15.8')
self.assertEqual(content['grpc'], '1.33.2')

def test_old_protobuf(self):
async def test_old_protobuf(self):
"""A function app with the following requirements.txt:
azure-functions==1.5.0
Expand All @@ -146,7 +146,7 @@ def test_old_protobuf(self):
self.assertIn(content['google.protobuf'], '3.8.0')
self.assertIn(content['grpc'], '1.27.1')

def test_debug_logging_disabled(self):
async def test_debug_logging_disabled(self):
"""An HttpTrigger function app with 'azure-functions' library
should return 200 and by default customer debug logging should be
disabled.
Expand All @@ -173,7 +173,7 @@ def test_debug_logging_disabled(self):
self.assertIn('logging error', func_log)
self.assertNotIn('logging debug', func_log)

def test_debug_logging_enabled(self):
async def test_debug_logging_enabled(self):
"""An HttpTrigger function app with 'azure-functions' library
should return 200 and with customer debug logging enabled, debug logs
should be written to container logs.
Expand Down Expand Up @@ -201,7 +201,7 @@ def test_debug_logging_enabled(self):
self.assertIn('logging error', func_log)
self.assertIn('logging debug', func_log)

def test_pinning_functions_to_older_version(self):
async def test_pinning_functions_to_older_version(self):
"""An HttpTrigger function app with 'azure-functions==1.11.1' library
should return 200 with the azure functions version set to 1.11.1
since dependency isolation is enabled by default for all py versions
Expand Down
2 changes: 2 additions & 0 deletions tests/unittests/test_enable_debug_logging_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def tearDownClass(cls):
def get_script_dir(cls):
return testutils.UNIT_TESTS_FOLDER / 'log_filtering_functions'

@pytest.mark.flaky(reruns=3)
def test_debug_logging_disabled(self):
"""
Verify when cx debug logging is disabled, cx function debug logs
Expand Down Expand Up @@ -128,6 +129,7 @@ def tearDownClass(cls):
def get_script_dir(cls):
return testutils.UNIT_TESTS_FOLDER / 'log_filtering_functions'

@pytest.mark.flaky(reruns=3)
def test_debug_logging_filtered(self):
"""
Verify when cx debug logging is enabled and host logging level
Expand Down
3 changes: 3 additions & 0 deletions tests/unittests/test_shared_memory_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import unittest
from unittest import skipIf

import pytest

from tests.utils import testutils
from azure_functions_worker.bindings.shared_memory_data_transfer \
import SharedMemoryMap
Expand All @@ -18,6 +20,7 @@
@skipIf(sys.platform == 'darwin', 'MacOS M1 machines do not correctly test the'
'shared memory filesystems and thus skipping'
' these tests for the time being')
@pytest.mark.flaky(reruns=3)
class TestSharedMemoryMap(testutils.SharedMemoryTestCase):
"""
Tests for SharedMemoryMap.
Expand Down

0 comments on commit 3c6471c

Please sign in to comment.