FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
coveragepy/tests/test_bytecode.py at main · coveragepy/coveragepy · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
coveragepy
/
coveragepy
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
520
Star
3.4k
Code
Issues
261
Pull requests
46
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
coveragepy
/
tests
/
test_bytecode.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (34 loc) · 1.39 KB
Breadcrumbs
coveragepy
/
tests
/
test_bytecode.py
Copy path
File metadata and controls
44 lines (34 loc) · 1.39 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.py's bytecode analysis."""
from
__future__
import
annotations
import
dis
from
textwrap
import
dedent
from
coverage
import
env
from
coverage
.
bytecode
import
ByteParser
,
op_set
from
tests
.
coveragetest
import
CoverageTest
class
BytecodeTest
(
CoverageTest
):
"""Tests for bytecode.py"""
def
test_code_objects
(
self
)
->
None
:
bp
=
ByteParser
(
text
=
dedent
(
"""
\
def f(x):
def g(y):
return {z for z in range(10)}
def j():
return [z for z in range(10)]
return g(x)
def h(x):
return x+1
"""
),
)
objs
=
list
(
bp
.
code_objects
())
expected
=
{
"<module>"
,
"f"
,
"g"
,
"j"
,
"h"
}
if
env
.
PYVERSION
<
(
3
,
12
):
# Comprehensions were compiled as implicit functions in earlier
# versions of Python.
expected
.
update
({
"<setcomp>"
,
"<listcomp>"
})
assert
{
c
.
co_name
for
c
in
objs
}
==
expected
def
test_op_set
(
self
)
->
None
:
opcodes
=
op_set
(
"LOAD_CONST"
,
"NON_EXISTENT_OPCODE"
,
"RETURN_VALUE"
)
assert
opcodes
==
{
dis
.
opmap
[
"LOAD_CONST"
],
dis
.
opmap
[
"RETURN_VALUE"
]}
Back
|
FazBrowse Home
|
New Git URL