FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
materials-RealPython/chatgpt-unit-tests-python/interval.py at master · ph3ll3r/materials-RealPython · GitHub
ph3ll3r
materials-RealPython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
materials-RealPython
/
chatgpt-unit-tests-python
/
interval.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
22 lines (18 loc) · 791 Bytes
Breadcrumbs
materials-RealPython
/
chatgpt-unit-tests-python
/
interval.py
Copy path
File metadata and controls
22 lines (18 loc) · 791 Bytes
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
import
pytest
def
in_interval
(
number
:
int
,
start
:
int
,
end
:
int
)
->
bool
:
return
start
<=
number
<=
end
@
pytest
.
mark
.
parametrize
(
"number, start, end, expected"
,
[
(
5
,
1
,
10
,
True
),
# Test case inside the interval
(
1
,
1
,
10
,
True
),
# Edge case: number equals start
(
10
,
1
,
10
,
True
),
# Edge case: number equals end
(
0
,
1
,
10
,
False
),
# Number below the interval
(
11
,
1
,
10
,
False
),
# Number above the interval
(
5
,
5
,
5
,
True
),
# Edge case: start equals end equals number
(
-
1
,
-
5
,
5
,
True
),
# Test case with negative numbers
(
-
6
,
-
5
,
5
,
False
),
# Number below the interval with negatives
],
)
def
test_in_interval
(
number
,
start
,
end
,
expected
):
assert
in_interval
(
number
,
start
,
end
)
==
expected
Back
|
FazBrowse Home
|
New Git URL