Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Exploratory Testing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ryan Thomas
Exploratory Testing
Commits
eda69ca6
Commit
eda69ca6
authored
3 years ago
by
Brady James Garvin
Browse files
Options
Downloads
Patches
Plain Diff
Matched code to the latest version of the testability examples.
parent
a170be5f
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
fuzzing/fuzz_find_smallest_positive.py
+2
-1
2 additions, 1 deletion
fuzzing/fuzz_find_smallest_positive.py
main.py
+37
-20
37 additions, 20 deletions
main.py
smallestpositive.kv
+8
-8
8 additions, 8 deletions
smallestpositive.kv
with
48 additions
and
29 deletions
.gitignore
+
1
−
0
View file @
eda69ca6
*~
*.pyc
*.pyo
__pycache__
.idea
This diff is collapsed.
Click to expand it.
fuzzing/fuzz_find_smallest_positive.py
+
2
−
1
View file @
eda69ca6
from
math
import
inf
from
random
import
randrange
,
choice
SUITE_TEMPLATE
=
'''
from math import inf
from unittest import TestCase
...
...
@@ -37,7 +38,7 @@ def generate_padding(smallest_positive):
def
generate_random_test
(
number
):
smallest_positive
=
choice
((
randrange
(
VALUE_LIMIT
),
inf
))
smallest_positive
=
choice
((
randrange
(
1
,
VALUE_LIMIT
),
inf
))
inputs
=
[
smallest_positive
]
# TODO
return
TEST_TEMPLATE
.
format
(
number
=
number
,
inputs
=
inputs
,
expected
=
smallest_positive
)
...
...
This diff is collapsed.
Click to expand it.
main.py
+
37
−
20
View file @
eda69ca6
...
...
@@ -2,42 +2,59 @@ from math import inf
from
kivy.app
import
App
from
kivy.uix.boxlayout
import
BoxLayout
from
kivy.properties
import
NumericProperty
,
StringProperty
from
kivy.properties
import
NumericProperty
,
StringProperty
,
ListProperty
class
Field
(
BoxLayout
):
label_text
=
StringProperty
()
index
=
NumericProperty
()
entry
=
StringProperty
()
class
Fields
(
BoxLayout
):
entries
=
ListProperty
([])
# elements are strings (some may not be valid numbers)
def
rebuild
(
self
):
while
len
(
self
.
children
)
>
len
(
self
.
entries
):
self
.
remove_widget
(
self
.
children
[
0
])
while
len
(
self
.
children
)
<
len
(
self
.
entries
):
self
.
add_widget
(
Field
(
index
=
len
(
self
.
children
)))
def
on_entries
(
self
,
_
,
__
):
self
.
rebuild
()
for
field
,
entry
in
zip
(
reversed
(
self
.
children
),
self
.
entries
):
field
.
entry
=
entry
class
SmallestPositiveApp
(
App
):
smallest_positive
=
NumericProperty
(
inf
)
entries
=
ListProperty
([])
# elements are strings (some may not be valid numbers)
result
=
NumericProperty
(
inf
)
def
add_field
(
self
):
container
=
self
.
root
.
ids
.
fields
container
.
add_widget
(
Field
(
label_text
=
f
'
Field #
{
len
(
container
.
children
)
}
:
'
))
self
.
entries
.
append
(
''
)
def
remove_field
(
self
):
container
=
self
.
root
.
ids
.
fields
if
len
(
container
.
children
)
>
0
:
container
.
remove_widget
(
container
.
children
[
0
])
try
:
self
.
entries
.
pop
()
except
IndexError
:
pass
@staticmethod
def
_find_smallest_positive
(
valu
es
):
def
_find_smallest_positive
(
entri
es
):
smallest_positive
=
inf
for
value
in
values
:
for
entry
in
entries
:
try
:
value
=
float
(
entry
)
if
0
<
value
<
smallest_positive
:
smallest_positive
=
value
return
smallest_positive
def
update
(
self
):
container
=
self
.
root
.
ids
.
fields
values
=
[]
for
field
in
container
.
children
:
try
:
values
.
append
(
float
(
field
.
ids
.
input
.
text
))
except
ValueError
:
pass
self
.
smallest_positive
=
SmallestPositiveApp
.
_find_smallest_positive
(
values
)
return
smallest_positive
def
on_entries
(
self
,
_
,
__
):
self
.
result
=
SmallestPositiveApp
.
_find_smallest_positive
(
self
.
entries
)
def
set_entry
(
self
,
index
,
entry
):
self
.
entries
[
index
]
=
entry
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
smallestpositive.kv
+
8
−
8
View file @
eda69ca6
BoxLayout:
orientation: 'vertical'
BoxLayout:
id: fields
orientation: 'vertical'
Fields:
entries: app.entries
size_hint: (1.0, 6.0)
BoxLayout:
orientation: 'horizontal'
...
...
@@ -15,18 +14,19 @@ BoxLayout:
font_size: sp(24)
on_press: app.remove_field()
Label:
id: result
text: f'Smallest Positive: {app.smallest_positive}'
text: f'Smallest Positive: {app.result}'
font_size: sp(24)
<Fields>:
orientation: 'vertical'
<Field>:
orientation: 'horizontal'
Label:
text:
root.label_text
text:
f'Field #{root.index}: '
font_size: sp(24)
TextInput:
id: input
multiline: False
write_tab: False
font_size: sp(24)
on_text: app.
update(
)
on_text: app.
set_entry(root.index, self.text
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment