Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
internewshid
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
Container registry
Model registry
Operate
Environments
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
aptivate
client-projects
internewshid
Commits
68023b8e
Commit
68023b8e
authored
9 years ago
by
Martin Burchell
Browse files
Options
Downloads
Patches
Plain Diff
Added exception for when tab does not exist
parent
adcec33d
Branches
Branches containing commit
No related tags found
2 merge requests
!23
Tabbed view header styling
,
!19
Tab registry
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
django/website/tabbed_page/tab_pool.py
+15
-1
15 additions, 1 deletion
django/website/tabbed_page/tab_pool.py
django/website/tabbed_page/tests/registration_tests.py
+15
-2
15 additions, 2 deletions
django/website/tabbed_page/tests/registration_tests.py
with
30 additions
and
3 deletions
django/website/tabbed_page/tab_pool.py
+
15
−
1
View file @
68023b8e
_pool
=
{}
class
MissingTabError
(
Exception
):
pass
def
register_tab
(
name
,
tab
):
global
_pool
_pool
[
name
]
=
tab
...
...
@@ -9,4 +13,14 @@ def register_tab(name, tab):
def
get_tab
(
name
):
global
_pool
return
_pool
[
name
]
try
:
return
_pool
[
name
]
except
KeyError
:
raise
MissingTabError
()
def
clear_tabs
():
# Currently only used in test code
global
_pool
_pool
=
{}
This diff is collapsed.
Click to expand it.
django/website/tabbed_page/tests/registration_tests.py
+
15
−
2
View file @
68023b8e
import
pytest
from
..tab_pool
import
register_tab
,
get_tab
from
..tab_pool
import
(
register_tab
,
get_tab
,
clear_tabs
,
MissingTabError
,
)
def
setup_function
(
function
):
clear_tabs
()
class
TestTab
(
object
):
...
...
@@ -12,7 +21,11 @@ def tab():
return
TestTab
()
@pytest.mark.django_db
def
test_tab_is_registered
(
tab
):
register_tab
(
'
test-tab
'
,
tab
)
assert
get_tab
(
'
test-tab
'
)
==
tab
def
test_exception_when_tab_not_registered
(
tab
):
with
pytest
.
raises
(
MissingTabError
):
get_tab
(
'
test-tab
'
)
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