Skip to content

Commit

Permalink
test: non json serializable type error with appmap
Browse files Browse the repository at this point in the history
  • Loading branch information
zermelo-wisen committed May 28, 2024
1 parent 6a6dcc1 commit 8efcbba
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 38 deletions.
118 changes: 81 additions & 37 deletions _appmap/test/data/pytest/expected/pytest.appmap.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,95 +8,133 @@
"name": "appmap",
"url": "https://github.com/applandinc/appmap-python"
},
"source_location": "test_simple.py:5",
"name": "hello world",
"feature": "Hello world",
"app": "Simple",
"recorder": {
"name": "pytest",
"type": "tests"
},
"source_location": "test_simple.py:5",
"name": "hello world",
"feature": "Hello world",
"test_status": "succeeded"
},
"events": [
{
"defined_class": "simple.Simple",
"method_id": "hello_world",
"path": "simple.py",
"lineno": 8,
"static": false,
"receiver": {
"class": "simple.Simple",
"kind": "req",
"value": "<simple.Simple object at 0xabcdef>",
"name": "self",
"value": "<simple.Simple object at 0xabcdef>"
"class": "simple.Simple"
},
"parameters": [],
"id": 1,
"event": "call",
"thread_id": 1
"thread_id": 1,
"defined_class": "simple.Simple",
"method_id": "hello_world",
"path": "simple.py",
"lineno": 16
},
{
"static": false,
"receiver": {
"kind": "req",
"value": "<simple.Simple object at 0xabcdef>",
"name": "self",
"class": "simple.Simple"
},
"parameters": [],
"id": 2,
"event": "call",
"thread_id": 1,
"defined_class": "simple.Simple",
"method_id": "hello",
"method_id": "get_non_json_serializable",
"path": "simple.py",
"lineno": 2,
"lineno": 13
},
{
"static": false,
"receiver": {
"class": "simple.Simple",
"kind": "req",
"value": "<simple.Simple object at 0xabcdef>",
"name": "self",
"value": "<simple.Simple object at 0xabcdef>"
"class": "simple.Simple"
},
"parameters": [],
"id": 2,
"id": 3,
"event": "call",
"thread_id": 1
"thread_id": 1,
"defined_class": "simple.Simple",
"method_id": "hello",
"path": "simple.py",
"lineno": 7
},
{
"return_value": {
"class": "builtins.str",
"value": "'Hello'"
"value": "'Hello'",
"class": "builtins.str"
},
"parent_id": 2,
"id": 3,
"parent_id": 3,
"id": 4,
"event": "return",
"thread_id": 1
},
{
"defined_class": "simple.Simple",
"method_id": "world",
"path": "simple.py",
"lineno": 5,
"static": false,
"receiver": {
"class": "simple.Simple",
"kind": "req",
"value": "<simple.Simple object at 0xabcdef>",
"name": "self",
"value": "<simple.Simple object at 0xabcdef>"
"class": "simple.Simple"
},
"parameters": [],
"id": 4,
"id": 5,
"event": "call",
"thread_id": 1,
"defined_class": "simple.Simple",
"method_id": "world",
"path": "simple.py",
"lineno": 10
},
{
"return_value": {
"value": "'world!'",
"class": "builtins.str"
},
"parent_id": 5,
"id": 6,
"event": "return",
"thread_id": 1
},
{
"return_value": {
"class": "builtins.str",
"value": "'world!'"
"value": "{0: 'Hello', 1: 'world!'}",
"class": "builtins.dict",
"properties": [
{
"name": "0",
"class": "builtins.str"
},
{
"name": "1",
"class": "builtins.str"
}
],
"size": 2
},
"parent_id": 4,
"id": 5,
"parent_id": 2,
"id": 7,
"event": "return",
"thread_id": 1
},
{
"return_value": {
"class": "builtins.str",
"value": "'Hello world!'"
"value": "'Hello world!'",
"class": "builtins.str"
},
"parent_id": 1,
"id": 6,
"id": 8,
"event": "return",
"thread_id": 1
}
Expand All @@ -110,22 +148,28 @@
"name": "Simple",
"type": "class",
"children": [
{
"name": "get_non_json_serializable",
"type": "function",
"location": "simple.py:13",
"static": false
},
{
"name": "hello",
"type": "function",
"location": "simple.py:2",
"location": "simple.py:7",
"static": false
},
{
"name": "hello_world",
"type": "function",
"location": "simple.py:8",
"location": "simple.py:16",
"static": false
},
{
"name": "world",
"type": "function",
"location": "simple.py:5",
"location": "simple.py:10",
"static": false
}
]
Expand Down
11 changes: 10 additions & 1 deletion _appmap/test/data/pytest/simple.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import numpy

zero = numpy.int64(0)
one = numpy.int64(1)

class Simple:
def hello(self):
return "Hello"

def world(self):
return "world!"

def get_non_json_serializable(self):
return { zero: self.hello(), one: self.world() }

def hello_world(self):
return "%s %s" % (self.hello(), self.world())
result = self.get_non_json_serializable()
return "%s %s" % (result[zero], result[one])
Loading

0 comments on commit 8efcbba

Please sign in to comment.