Skip to content

Commit f4d59f7

Browse files
committed
formatting
1 parent f2bc6e8 commit f4d59f7

File tree

2 files changed

+61
-65
lines changed

2 files changed

+61
-65
lines changed

posthog/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ def capture(
291291
require("properties", properties, dict)
292292
require("event", event, string_types)
293293

294-
295294
msg = {
296295
"properties": properties,
297296
"timestamp": timestamp,

posthog/test/test_client.py

Lines changed: 61 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ def test_basic_super_properties(self):
107107
self.assertEqual(msg["properties"]["source"], "repo-name")
108108

109109
def test_basic_capture_exception(self):
110-
111110
with mock.patch.object(Client, "capture", return_value=None) as patch_capture:
112111
client = self.client
113112
exception = Exception("test exception")
@@ -135,7 +134,6 @@ def test_basic_capture_exception(self):
135134
)
136135

137136
def test_basic_capture_exception_with_distinct_id(self):
138-
139137
with mock.patch.object(Client, "capture", return_value=None) as patch_capture:
140138
client = self.client
141139
exception = Exception("test exception")
@@ -163,7 +161,6 @@ def test_basic_capture_exception_with_distinct_id(self):
163161
)
164162

165163
def test_basic_capture_exception_with_correct_host_generation(self):
166-
167164
with mock.patch.object(Client, "capture", return_value=None) as patch_capture:
168165
client = Client(FAKE_TEST_API_KEY, on_error=self.set_fail, host="https://aloha.com")
169166
exception = Exception("test exception")
@@ -191,7 +188,6 @@ def test_basic_capture_exception_with_correct_host_generation(self):
191188
)
192189

193190
def test_basic_capture_exception_with_correct_host_generation_for_server_hosts(self):
194-
195191
with mock.patch.object(Client, "capture", return_value=None) as patch_capture:
196192
client = Client(FAKE_TEST_API_KEY, on_error=self.set_fail, host="https://app.posthog.com")
197193
exception = Exception("test exception")
@@ -219,7 +215,6 @@ def test_basic_capture_exception_with_correct_host_generation_for_server_hosts(s
219215
)
220216

221217
def test_basic_capture_exception_with_no_exception_given(self):
222-
223218
with mock.patch.object(Client, "capture", return_value=None) as patch_capture:
224219
client = self.client
225220
try:
@@ -256,10 +251,8 @@ def test_basic_capture_exception_with_no_exception_given(self):
256251
self.assertEqual(capture_call[2]["$exception_list"][0]["stacktrace"]["frames"][0]["in_app"], True)
257252

258253
def test_basic_capture_exception_with_no_exception_happening(self):
259-
260254
with mock.patch.object(Client, "capture", return_value=None) as patch_capture:
261255
with self.assertLogs("posthog", level="WARNING") as logs:
262-
263256
client = self.client
264257
client.capture_exception()
265258

@@ -1131,87 +1124,91 @@ def test_default_properties_get_added_properly(self, patch_decide):
11311124
disable_geoip=False,
11321125
)
11331126

1134-
@parameterized.expand([
1135-
# name, sys_platform, version_info, expected_runtime, expected_version, expected_os, expected_os_version, platform_method, platform_return, distro_info
1136-
(
1137-
"macOS",
1138-
"darwin",
1139-
(3, 8, 10),
1140-
"MockPython",
1141-
"3.8.10",
1142-
"Mac OS X",
1143-
"10.15.7",
1144-
"mac_ver",
1145-
("10.15.7", "", ""),
1146-
None,
1147-
),
1148-
(
1149-
"Windows",
1150-
"win32",
1151-
(3, 8, 10),
1152-
"MockPython",
1153-
"3.8.10",
1154-
"Windows",
1155-
"10",
1156-
"win32_ver",
1157-
("10", "", "", ""),
1158-
None,
1159-
),
1160-
(
1161-
"Linux",
1162-
"linux",
1163-
(3, 8, 10),
1164-
"MockPython",
1165-
"3.8.10",
1166-
"Linux",
1167-
"20.04",
1168-
None,
1169-
None,
1170-
{"version": "20.04"},
1171-
),
1172-
])
1127+
@parameterized.expand(
1128+
[
1129+
# name, sys_platform, version_info, expected_runtime, expected_version, expected_os, expected_os_version, platform_method, platform_return, distro_info
1130+
(
1131+
"macOS",
1132+
"darwin",
1133+
(3, 8, 10),
1134+
"MockPython",
1135+
"3.8.10",
1136+
"Mac OS X",
1137+
"10.15.7",
1138+
"mac_ver",
1139+
("10.15.7", "", ""),
1140+
None,
1141+
),
1142+
(
1143+
"Windows",
1144+
"win32",
1145+
(3, 8, 10),
1146+
"MockPython",
1147+
"3.8.10",
1148+
"Windows",
1149+
"10",
1150+
"win32_ver",
1151+
("10", "", "", ""),
1152+
None,
1153+
),
1154+
(
1155+
"Linux",
1156+
"linux",
1157+
(3, 8, 10),
1158+
"MockPython",
1159+
"3.8.10",
1160+
"Linux",
1161+
"20.04",
1162+
None,
1163+
None,
1164+
{"version": "20.04"},
1165+
),
1166+
]
1167+
)
11731168
def test_mock_system_context(
1174-
self,
1175-
_name,
1176-
sys_platform,
1177-
version_info,
1178-
expected_runtime,
1179-
expected_version,
1180-
expected_os,
1181-
expected_os_version,
1182-
platform_method,
1183-
platform_return,
1184-
distro_info
1169+
self,
1170+
_name,
1171+
sys_platform,
1172+
version_info,
1173+
expected_runtime,
1174+
expected_version,
1175+
expected_os,
1176+
expected_os_version,
1177+
platform_method,
1178+
platform_return,
1179+
distro_info,
11851180
):
11861181
"""Test that we can mock platform and sys for testing system_context"""
1187-
with mock.patch('posthog.client.platform') as mock_platform:
1188-
with mock.patch('posthog.client.sys') as mock_sys:
1182+
with mock.patch("posthog.client.platform") as mock_platform:
1183+
with mock.patch("posthog.client.sys") as mock_sys:
11891184
# Set up common mocks
11901185
mock_platform.python_implementation.return_value = expected_runtime
11911186
mock_sys.version_info = version_info
11921187
mock_sys.platform = sys_platform
1193-
1188+
11941189
# Set up platform-specific mocks
11951190
if platform_method:
11961191
getattr(mock_platform, platform_method).return_value = platform_return
1197-
1192+
11981193
# Special handling for Linux which uses distro module
11991194
if sys_platform == "linux":
12001195
# Directly patch the get_os_info function to return our expected values
1201-
with mock.patch('posthog.client.get_os_info', return_value=(expected_os, expected_os_version)):
1196+
with mock.patch("posthog.client.get_os_info", return_value=(expected_os, expected_os_version)):
12021197
from posthog.client import system_context
1198+
12031199
context = system_context()
12041200
else:
12051201
# Get system context for non-Linux platforms
12061202
from posthog.client import system_context
1203+
12071204
context = system_context()
1208-
1205+
12091206
# Verify results
12101207
expected_context = {
12111208
"$python_runtime": expected_runtime,
12121209
"$python_version": expected_version,
12131210
"$os": expected_os,
12141211
"$os_version": expected_os_version,
12151212
}
1216-
1213+
12171214
assert context == expected_context

0 commit comments

Comments
 (0)