Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
26f7057b
Commit
26f7057b
authored
May 28, 2015
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 24297: Add a unittest that Lib/symbol.py is in sync with Grammar
parent
6e6883f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
Lib/test/test_symbol.py
Lib/test/test_symbol.py
+45
-0
No files found.
Lib/test/test_symbol.py
0 → 100644
View file @
26f7057b
import
unittest
from
test
import
support
import
filecmp
import
os
import
sys
import
subprocess
SYMBOL_FILE
=
support
.
findfile
(
'symbol.py'
)
GRAMMAR_FILE
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'Include'
,
'graminit.h'
)
TEST_PY_FILE
=
'symbol_test.py'
class
TestSymbolGeneration
(
unittest
.
TestCase
):
def
_copy_file_without_generated_symbols
(
self
,
source_file
,
dest_file
):
with
open
(
source_file
,
'rb'
)
as
fp
:
lines
=
fp
.
readlines
()
nl
=
lines
[
0
][
len
(
lines
[
0
].
rstrip
()):]
with
open
(
dest_file
,
'wb'
)
as
fp
:
fp
.
writelines
(
lines
[:
lines
.
index
(
b"#--start constants--"
+
nl
)
+
1
])
fp
.
writelines
(
lines
[
lines
.
index
(
b"#--end constants--"
+
nl
):])
def
_generate_symbols
(
self
,
grammar_file
,
target_symbol_py_file
):
proc
=
subprocess
.
Popen
([
sys
.
executable
,
SYMBOL_FILE
,
grammar_file
,
target_symbol_py_file
],
stderr
=
subprocess
.
PIPE
)
stderr
=
proc
.
communicate
()[
1
]
return
proc
.
returncode
,
stderr
@
unittest
.
skipIf
(
not
os
.
path
.
exists
(
GRAMMAR_FILE
),
'test only works from source build directory'
)
def
test_real_grammar_and_symbol_file
(
self
):
self
.
_copy_file_without_generated_symbols
(
SYMBOL_FILE
,
TEST_PY_FILE
)
self
.
addCleanup
(
support
.
unlink
,
TEST_PY_FILE
)
self
.
assertFalse
(
filecmp
.
cmp
(
SYMBOL_FILE
,
TEST_PY_FILE
))
self
.
assertEqual
((
0
,
b''
),
self
.
_generate_symbols
(
GRAMMAR_FILE
,
TEST_PY_FILE
))
self
.
assertTrue
(
filecmp
.
cmp
(
SYMBOL_FILE
,
TEST_PY_FILE
))
if
__name__
==
"__main__"
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment