Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
df08a2eb
Commit
df08a2eb
authored
Feb 26, 2020
by
Flavio TARSETTI
Browse files
[test/widget] improve unit tests and correct typos
parent
f698c6d1
Pipeline
#37711
passed with stage
in 12 minutes and 59 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
beat/editor/test/test_toolchaineditor.py
View file @
df08a2eb
...
...
@@ -27,7 +27,6 @@ import pytest
import
simplejson
as
json
from
PyQt5.QtCore
import
QFile
from
PyQt5.QtCore
import
QIODevice
from
PyQt5.QtWidgets
import
QGraphicsScene
from
PyQt5.QtWidgets
import
QGraphicsView
...
...
@@ -45,11 +44,10 @@ from .conftest import prefix
def
toolchain_config
():
config_data
=
{}
_file
=
QFile
(
":/resources/toolchain_style_config"
)
if
_file
.
open
(
QFile
.
ReadOnly
|
QIODevice
.
Text
):
config_data
=
json
.
loads
(
_file
.
readAll
().
data
().
decode
(
"utf-8"
))
return
config_data
file_
=
QFile
(
":/resources/toolchain_style_config"
)
is_open
=
file_
.
open
(
QFile
.
ReadOnly
|
QFile
.
Text
)
assert
is_open
return
json
.
loads
(
file_
.
readAll
().
data
().
decode
(
"utf-8"
))
@
pytest
.
fixture
()
...
...
@@ -77,14 +75,10 @@ def get_valid_toolchains(test_prefix):
class
TestToolchainScene
:
def
test_good_init
(
self
,
qtbot
,
scene_config
):
configuration
=
{
"grid_size"
:
scene_config
[
"grid_size"
],
"grid_color"
:
scene_config
[
"grid_color"
],
}
scene
=
ToolchainScene
(
configuration
)
scene
=
ToolchainScene
(
scene_config
)
assert
isinstance
(
scene
,
QGraphicsScene
)
assert
scene
.
grid_size
==
config
uration
[
"grid_size"
]
assert
scene
.
grid_color
==
config
uration
[
"grid_color"
]
assert
scene
.
grid_size
==
scene_
config
[
"grid_size"
]
assert
scene
.
grid_color
==
scene_
config
[
"grid_color"
]
def
test_bad_init
(
self
,
qtbot
,
scene_config
):
configuration
=
{
"bad"
:
1000
}
...
...
@@ -115,9 +109,8 @@ class TestToolchainScene:
assert
str
(
excinfo
.
value
)
==
expected_exception_message
@
pytest
.
mark
.
parametrize
(
"toolchain"
,
get_valid_toolchains
(
prefix
))
def
test_add_scene_to_view
(
self
,
qtbot
,
toolchain
):
configuration
=
{
"grid_size"
:
1000
,
"grid_color"
:
[
220
,
220
,
220
,
220
]}
scene
=
ToolchainScene
(
configuration
)
def
test_add_scene_to_view
(
self
,
qtbot
,
toolchain
,
scene_config
):
scene
=
ToolchainScene
(
scene_config
)
toolchainview
=
ToolchainView
(
toolchain
)
assert
toolchainview
.
scene
()
is
None
...
...
beat/editor/widgets/toolchaineditor.py
View file @
df08a2eb
...
...
@@ -35,7 +35,6 @@ from PyQt5.QtCore import QPointF
from
PyQt5.QtCore
import
pyqtSignal
from
PyQt5.QtCore
import
pyqtSlot
from
PyQt5.QtCore
import
QFile
from
PyQt5.QtCore
import
QIODevice
from
PyQt5.QtGui
import
QColor
from
PyQt5.QtGui
import
QBrush
...
...
@@ -1426,9 +1425,9 @@ class Toolchain(QWidget):
self
.
autonomous_loop_evaluator_list
=
[]
config_data
=
{}
_
file
=
QFile
(
":/resources/toolchain_style_config"
)
if
_
file
.
open
(
QFile
.
ReadOnly
|
Q
IODevic
e
.
Text
):
config_data
=
json
.
loads
(
_
file
.
readAll
().
data
().
decode
(
"utf-8"
))
file
_
=
QFile
(
":/resources/toolchain_style_config"
)
if
file
_
.
open
(
QFile
.
ReadOnly
|
Q
Fil
e
.
Text
):
config_data
=
json
.
loads
(
file
_
.
readAll
().
data
().
decode
(
"utf-8"
))
self
.
scene_config
=
config_data
[
"toolchainscene_config"
]
self
.
scene
=
ToolchainScene
(
self
.
scene_config
)
...
...
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