FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/swift/codegen/test/utils.py at codeql-cli-2.11.3 · github/codeql · GitHub
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10.1k
Code
Issues
1k
Pull requests
468
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
swift
/
codegen
/
test
/
utils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
65 lines (47 loc) · 1.61 KB
Breadcrumbs
codeql
/
swift
/
codegen
/
test
/
utils.py
Copy path
File metadata and controls
65 lines (47 loc) · 1.61 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import
pathlib
from
unittest
import
mock
import
pytest
from
swift
.
codegen
.
lib
import
render
,
schema
,
paths
schema_dir
=
pathlib
.
Path
(
"a"
,
"dir"
)
schema_file
=
schema_dir
/
"schema.yml"
dbscheme_file
=
pathlib
.
Path
(
"another"
,
"dir"
,
"test.dbscheme"
)
def
write
(
out
,
contents
=
""
):
out
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
with
open
(
out
,
"w"
)
as
out
:
out
.
write
(
contents
)
@
pytest
.
fixture
def
renderer
():
return
mock
.
Mock
(
spec
=
render
.
Renderer
(
""
))
@
pytest
.
fixture
def
opts
():
ret
=
mock
.
MagicMock
()
ret
.
swift_dir
=
paths
.
swift_dir
return
ret
@
pytest
.
fixture
(
autouse
=
True
)
def
override_paths
(
tmp_path
):
with
mock
.
patch
(
"swift.codegen.lib.paths.swift_dir"
,
tmp_path
):
yield
@
pytest
.
fixture
def
input
(
opts
,
tmp_path
):
opts
.
schema
=
tmp_path
/
schema_file
with
mock
.
patch
(
"swift.codegen.lib.schema.load_file"
)
as
load_mock
:
load_mock
.
return_value
=
schema
.
Schema
([])
yield
load_mock
.
return_value
assert
load_mock
.
mock_calls
==
[
mock
.
call
(
opts
.
schema
),
],
load_mock
.
mock_calls
@
pytest
.
fixture
def
dbscheme_input
(
opts
,
tmp_path
):
opts
.
dbscheme
=
tmp_path
/
dbscheme_file
with
mock
.
patch
(
"swift.codegen.lib.dbscheme.iterload"
)
as
load_mock
:
load_mock
.
entities
=
[]
load_mock
.
side_effect
=
lambda
_
:
load_mock
.
entities
yield
load_mock
assert
load_mock
.
mock_calls
==
[
mock
.
call
(
opts
.
dbscheme
),
],
load_mock
.
mock_calls
def
run_generation
(
generate
,
opts
,
renderer
):
output
=
{}
renderer
.
render
.
side_effect
=
lambda
data
,
out
:
output
.
__setitem__
(
out
,
data
)
generate
(
opts
,
renderer
)
return
output
Back
|
FazBrowse Home
|
New Git URL