@@ -781,13 +781,15 @@ Here's an example of how you can test your synchronous resolvers:
781
781
782
782
```python
783
783
import pytest
784
+ from pathlib import Path
785
+
784
786
from src.index import app # import the instance of AppSyncResolver from your code
785
787
786
788
def test_direct_resolver():
787
789
# Load mock event from a file
788
- json_file = "appSyncDirectResolver.json"
789
- fh = open(file)
790
- mock_event = json.load(fh )
790
+ json_file_path = Path( "appSyncDirectResolver.json")
791
+ with open(json_file_path) as json_file:
792
+ mock_event = json.load(json_file )
791
793
792
794
# Call the implicit handler
793
795
result = app(mock_event, {})
@@ -822,14 +824,16 @@ And an example for testing asynchronous resolvers. Note that this requires the `
822
824
823
825
```python
824
826
import pytest
827
+ from pathlib import Path
828
+
825
829
from src.index import app # import the instance of AppSyncResolver from your code
826
830
827
831
@pytest.mark.asyncio
828
832
async def test_direct_resolver():
829
833
# Load mock event from a file
830
- json_file = "appSyncDirectResolver.json"
831
- fh = open(file)
832
- mock_event = json.load(fh )
834
+ json_file_path = Path( "appSyncDirectResolver.json")
835
+ with open(json_file_path) as json_file:
836
+ mock_event = json.load(json_file )
833
837
834
838
# Call the implicit handler
835
839
result = await app(mock_event, {})
0 commit comments