1
- From 0dedc1c573ddc4e87475eb03c64555cd54a72e92 Mon Sep 17 00:00:00 2001
2
- From: Trevor Gamblin <trevor.gamblin@windriver .com>
3
- Date: Mon, 7 Jun 2021 09:40:20 -0400
4
- Subject: [PATCH] Fix imports for tests
1
+ From 0136ca731cba8b056b3f2ff0e7df3953b94f1e87 Mon Sep 17 00:00:00 2001
2
+ From: Tim Orling <tim.orling@konsulko .com>
3
+ Date: Sun, 24 Dec 2023 09:41:57 -0800
4
+ Subject: [PATCH 1/2] test_functionality: convert line endings to Unix
5
5
6
- Signed-off-by: Trevor Gamblin <
[email protected] >
7
- ---
8
- Upstream-Status: Pending
6
+ Convert the Windows line endings with dos2unix to be like the
7
+ other files in tests/*
8
+
9
+ Upstream-Status: Submitted [https://github.com/sumerc/yappi/pull/164]
9
10
10
- tests/test_asyncio.py | 2 +-
11
- tests/test_asyncio_context_vars.py | 2 +-
12
- tests/test_functionality.py | 2 +-
13
- tests/test_hooks.py | 2 +-
14
- tests/test_tags.py | 2 +-
15
- 5 files changed, 6 insertions(+), 6 deletions(-)
11
+ Signed-off-by: Tim Orling <
[email protected] >
12
+ ---
13
+ tests/test_functionality.py | 3822 +++++++++++++++++------------------
14
+ 1 file changed, 1911 insertions(+), 1911 deletions(-)
16
15
17
- --- a/tests/test_asyncio.py
18
- +++ b/tests/test_asyncio.py
19
- @@ -2,7 +2,7 @@ import unittest
20
- import yappi
21
- import asyncio
22
- import threading
23
- - from utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
24
- + from .utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
25
-
26
-
27
- async def async_sleep(sec):
28
- --- a/tests/test_asyncio_context_vars.py
29
- +++ b/tests/test_asyncio_context_vars.py
30
- @@ -5,7 +5,7 @@ import contextvars
31
- import functools
32
- import time
33
- import os
34
- - import utils
35
- + import tests.utils as utils
36
- import yappi
37
-
38
- async_context_id = contextvars.ContextVar('async_context_id')
16
+ diff --git a/tests/test_functionality.py b/tests/test_functionality.py
17
+ index 0e99c47..38bbe67 100644
39
18
--- a/tests/test_functionality.py
40
19
+++ b/tests/test_functionality.py
41
- @@ -1,1916 +1,1916 @@
20
+ @@ -1,1911 +1,1911 @@
42
21
- import os
43
22
- import sys
44
23
- import time
@@ -47,7 +26,7 @@ Upstream-Status: Pending
47
26
- import yappi
48
27
- import _yappi
49
28
- import utils
50
- - import multiprocessing # added to fix http://bugs.python.org/issue15881 for > Py2.6
29
+ - import multiprocessing
51
30
- import subprocess
52
31
-
53
32
- _counter = 0
@@ -318,10 +297,10 @@ Upstream-Status: Pending
318
297
- def test_profile_decorator(self):
319
298
-
320
299
- def aggregate(func, stats):
321
- - fname = "tests/%s.profile" % ( func.__name__)
300
+ - fname = f "tests/{ func.__name__}.profile"
322
301
- try:
323
302
- stats.add(fname)
324
- - except IOError :
303
+ - except OSError :
325
304
- pass
326
305
- stats.save(fname)
327
306
- raise Exception("messing around")
@@ -1232,7 +1211,7 @@ Upstream-Status: Pending
1232
1211
- # TODO: I put dummy() to fix below, remove the comments after a while.
1233
1212
- self.assertTrue( # FIX: I see this fails sometimes?
1234
1213
- tsm is not None,
1235
- - ' Could not find "_MainThread". Found: %s' % (' , '.join(utils.get_stat_names(tstats))) )
1214
+ - f" Could not find \ "_MainThread\ ". Found: {' , '.join(utils.get_stat_names(tstats))}" )
1236
1215
-
1237
1216
- def test_ctx_stats(self):
1238
1217
- from threading import Thread
@@ -1312,7 +1291,7 @@ Upstream-Status: Pending
1312
1291
- # TODO: I put dummy() to fix below, remove the comments after a while.
1313
1292
- self.assertTrue( # FIX: I see this fails sometimes
1314
1293
- tsmain is not None,
1315
- - ' Could not find "_MainThread". Found: %s' % (' , '.join(utils.get_stat_names(stats))) )
1294
+ - f" Could not find \ "_MainThread\ ". Found: {' , '.join(utils.get_stat_names(stats))}" )
1316
1295
- self.assertTrue(1.0 > tst2.ttot >= 0.5)
1317
1296
- self.assertTrue(1.0 > tst1.ttot >= 0.5)
1318
1297
-
@@ -1369,7 +1348,7 @@ Upstream-Status: Pending
1369
1348
- ts = []
1370
1349
- for i in (0.01, 0.05, 0.1):
1371
1350
- t = threading.Thread(target=burn_cpu, args=(i, ))
1372
- - t.name = "burn_cpu-%s" % str(i)
1351
+ - t.name = f "burn_cpu-{ str(i)}"
1373
1352
- t.start()
1374
1353
- ts.append(t)
1375
1354
- for t in ts:
@@ -1396,10 +1375,7 @@ Upstream-Status: Pending
1396
1375
- def test_producer_consumer_with_queues(self):
1397
1376
- # we currently just stress yappi, no functionality test is done here.
1398
1377
- yappi.start()
1399
- - if utils.is_py3x():
1400
- - from queue import Queue
1401
- - else:
1402
- - from Queue import Queue
1378
+ - from queue import Queue
1403
1379
- from threading import Thread
1404
1380
- WORKER_THREAD_COUNT = 50
1405
1381
- WORK_ITEM_COUNT = 2000
@@ -1458,7 +1434,6 @@ Upstream-Status: Pending
1458
1434
- fsh = utils.find_stat_by_name(stats, "handler")
1459
1435
- self.assertTrue(fsh is not None)
1460
1436
-
1461
- - @unittest.skipIf(not sys.version_info >= (3, 2), "requires Python 3.2")
1462
1437
- def test_concurrent_futures(self):
1463
1438
- yappi.start()
1464
1439
- from concurrent.futures import ThreadPoolExecutor
@@ -1468,7 +1443,6 @@ Upstream-Status: Pending
1468
1443
- time.sleep(1.0)
1469
1444
- yappi.stop()
1470
1445
-
1471
- - @unittest.skipIf(not sys.version_info >= (3, 2), "requires Python 3.2")
1472
1446
- def test_barrier(self):
1473
1447
- yappi.start()
1474
1448
- b = threading.Barrier(2, timeout=1)
@@ -1962,8 +1936,8 @@ Upstream-Status: Pending
1962
1936
+ import unittest
1963
1937
+ import yappi
1964
1938
+ import _yappi
1965
- + import tests.utils as utils
1966
- + import multiprocessing # added to fix http://bugs.python.org/issue15881 for > Py2.6
1939
+ + import utils
1940
+ + import multiprocessing
1967
1941
+ import subprocess
1968
1942
+
1969
1943
+ _counter = 0
@@ -2234,10 +2208,10 @@ Upstream-Status: Pending
2234
2208
+ def test_profile_decorator(self):
2235
2209
+
2236
2210
+ def aggregate(func, stats):
2237
- + fname = "tests/%s.profile" % ( func.__name__)
2211
+ + fname = f "tests/{ func.__name__}.profile"
2238
2212
+ try:
2239
2213
+ stats.add(fname)
2240
- + except IOError :
2214
+ + except OSError :
2241
2215
+ pass
2242
2216
+ stats.save(fname)
2243
2217
+ raise Exception("messing around")
@@ -3007,8 +2981,8 @@ Upstream-Status: Pending
3007
2981
+
3008
2982
+ def test_issue_32(self):
3009
2983
+ '''
3010
- + Start yappi from different thread and we get Internal Error(15) as
3011
- + the current_ctx_id() called while enumerating the threads in start()
2984
+ + Start yappi from different thread and we get Internal Error(15) as
2985
+ + the current_ctx_id() called while enumerating the threads in start()
3012
2986
+ and as it does not swap to the enumerated ThreadState* the THreadState_GetDict()
3013
2987
+ returns wrong object and thus sets an invalid id for the _ctx structure.
3014
2988
+
@@ -3148,7 +3122,7 @@ Upstream-Status: Pending
3148
3122
+ # TODO: I put dummy() to fix below, remove the comments after a while.
3149
3123
+ self.assertTrue( # FIX: I see this fails sometimes?
3150
3124
+ tsm is not None,
3151
- + ' Could not find "_MainThread". Found: %s' % (' , '.join(utils.get_stat_names(tstats))) )
3125
+ + f" Could not find \ "_MainThread\ ". Found: {' , '.join(utils.get_stat_names(tstats))}" )
3152
3126
+
3153
3127
+ def test_ctx_stats(self):
3154
3128
+ from threading import Thread
@@ -3228,7 +3202,7 @@ Upstream-Status: Pending
3228
3202
+ # TODO: I put dummy() to fix below, remove the comments after a while.
3229
3203
+ self.assertTrue( # FIX: I see this fails sometimes
3230
3204
+ tsmain is not None,
3231
- + ' Could not find "_MainThread". Found: %s' % (' , '.join(utils.get_stat_names(stats))) )
3205
+ + f" Could not find \ "_MainThread\ ". Found: {' , '.join(utils.get_stat_names(stats))}" )
3232
3206
+ self.assertTrue(1.0 > tst2.ttot >= 0.5)
3233
3207
+ self.assertTrue(1.0 > tst1.ttot >= 0.5)
3234
3208
+
@@ -3285,7 +3259,7 @@ Upstream-Status: Pending
3285
3259
+ ts = []
3286
3260
+ for i in (0.01, 0.05, 0.1):
3287
3261
+ t = threading.Thread(target=burn_cpu, args=(i, ))
3288
- + t.name = "burn_cpu-%s" % str(i)
3262
+ + t.name = f "burn_cpu-{ str(i)}"
3289
3263
+ t.start()
3290
3264
+ ts.append(t)
3291
3265
+ for t in ts:
@@ -3312,10 +3286,7 @@ Upstream-Status: Pending
3312
3286
+ def test_producer_consumer_with_queues(self):
3313
3287
+ # we currently just stress yappi, no functionality test is done here.
3314
3288
+ yappi.start()
3315
- + if utils.is_py3x():
3316
- + from queue import Queue
3317
- + else:
3318
- + from Queue import Queue
3289
+ + from queue import Queue
3319
3290
+ from threading import Thread
3320
3291
+ WORKER_THREAD_COUNT = 50
3321
3292
+ WORK_ITEM_COUNT = 2000
@@ -3374,7 +3345,6 @@ Upstream-Status: Pending
3374
3345
+ fsh = utils.find_stat_by_name(stats, "handler")
3375
3346
+ self.assertTrue(fsh is not None)
3376
3347
+
3377
- + @unittest.skipIf(not sys.version_info >= (3, 2), "requires Python 3.2")
3378
3348
+ def test_concurrent_futures(self):
3379
3349
+ yappi.start()
3380
3350
+ from concurrent.futures import ThreadPoolExecutor
@@ -3384,7 +3354,6 @@ Upstream-Status: Pending
3384
3354
+ time.sleep(1.0)
3385
3355
+ yappi.stop()
3386
3356
+
3387
- + @unittest.skipIf(not sys.version_info >= (3, 2), "requires Python 3.2")
3388
3357
+ def test_barrier(self):
3389
3358
+ yappi.start()
3390
3359
+ b = threading.Barrier(2, timeout=1)
@@ -3871,25 +3840,6 @@ Upstream-Status: Pending
3871
3840
+ # import sys;sys.argv = ['', 'BasicUsage.test_run_as_script']
3872
3841
+ # import sys;sys.argv = ['', 'MultithreadedScenarios.test_subsequent_profile']
3873
3842
+ unittest.main()
3874
- --- a/tests/test_hooks.py
3875
- +++ b/tests/test_hooks.py
3876
- @@ -5,7 +5,7 @@ import unittest
3877
- import time
3878
-
3879
- import yappi
3880
- - import utils
3881
- + import tests.utils as utils
3882
-
3883
-
3884
- def a():
3885
- --- a/tests/test_tags.py
3886
- +++ b/tests/test_tags.py
3887
- @@ -2,7 +2,7 @@ import unittest
3888
- import yappi
3889
- import threading
3890
- import time
3891
- - from utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
3892
- + from .utils import YappiUnitTestCase, find_stat_by_name, burn_cpu, burn_io
3893
-
3894
-
3895
- class MultiThreadTests(YappiUnitTestCase):
3843
+ - -
3844
+ 2.34.1
3845
+
0 commit comments