Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
erp5
Commits
788a154b
Commit
788a154b
authored
Sep 27, 2011
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define __getattr__ on non-Browser classes rather than modifying the class dictionary
parent
3db880ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
erp5/util/testbrowser/browser.py
erp5/util/testbrowser/browser.py
+13
-12
No files found.
erp5/util/testbrowser/browser.py
View file @
788a154b
...
@@ -54,6 +54,13 @@ def measurementMetaClass(prefix):
...
@@ -54,6 +54,13 @@ def measurementMetaClass(prefix):
besides of Browser.
besides of Browser.
"""
"""
def
__new__
(
metacls
,
name
,
bases
,
dictionary
):
def
__new__
(
metacls
,
name
,
bases
,
dictionary
):
def
nonBrowserClass_getattr
(
self
,
attribute
):
"""
Some attributes, such as lastRequestSeconds, are only defined in the
Browser class
"""
return
getattr
(
self
.
browser
,
attribute
)
def
timeInSecondDecorator
(
method
):
def
timeInSecondDecorator
(
method
):
def
wrapper
(
self
,
*
args
,
**
kwargs
):
def
wrapper
(
self
,
*
args
,
**
kwargs
):
"""
"""
...
@@ -103,14 +110,8 @@ def measurementMetaClass(prefix):
...
@@ -103,14 +110,8 @@ def measurementMetaClass(prefix):
if
callable
(
attribute
)
and
not
getattr
(
attribute
,
'__is_wrapper__'
,
False
):
if
callable
(
attribute
)
and
not
getattr
(
attribute
,
'__is_wrapper__'
,
False
):
applyMeasure
(
attribute
)
applyMeasure
(
attribute
)
# lastRequestSeconds properties are only defined on classes inheriting
# from zope.testbrowser.browser.Browser, so create these properties for
# all other classes too
if
'Browser'
not
in
bases
[
0
].
__name__
:
if
'Browser'
not
in
bases
[
0
].
__name__
:
time_method
=
lambda
self
:
self
.
browser
.
lastRequestSeconds
dictionary
[
'__getattr__'
]
=
nonBrowserClass_getattr
time_method
.
func_name
=
'lastRequestSeconds'
time_method
.
__doc__
=
Browser
.
lastRequestSeconds
.
__doc__
dictionary
[
'lastRequestSeconds'
]
=
property
(
time_method
)
return
super
(
MeasurementMetaClass
,
return
super
(
MeasurementMetaClass
,
metacls
).
__new__
(
metacls
,
name
,
bases
,
dictionary
)
metacls
).
__new__
(
metacls
,
name
,
bases
,
dictionary
)
...
@@ -566,7 +567,7 @@ class MainForm(Form):
...
@@ -566,7 +567,7 @@ class MainForm(Form):
class attribute name, if class_attribute
class attribute name, if class_attribute
parameter is given.
parameter is given.
"""
"""
self
.
browser
.
_logger
.
debug
(
self
.
_logger
.
debug
(
"Submitting (name='%s', label='%s', class='%s')"
%
(
name
,
label
,
"Submitting (name='%s', label='%s', class='%s')"
%
(
name
,
label
,
class_attribute
))
class_attribute
))
...
@@ -645,7 +646,7 @@ class MainForm(Form):
...
@@ -645,7 +646,7 @@ class MainForm(Form):
value
=
item
value
=
item
break
break
self
.
browser
.
_logger
.
debug
(
"select_id='%s', label='%s', value='%s'"
%
\
self
.
_logger
.
debug
(
"select_id='%s', label='%s', value='%s'"
%
\
(
select_name
,
label
,
value
))
(
select_name
,
label
,
value
))
select_control
.
getControl
(
label
=
label
,
value
=
value
,
select_control
.
getControl
(
label
=
label
,
value
=
value
,
...
@@ -668,13 +669,13 @@ class MainForm(Form):
...
@@ -668,13 +669,13 @@ class MainForm(Form):
into the page content?
into the page content?
"""
"""
if
'Logged In as'
in
self
.
browser
.
contents
:
if
'Logged In as'
in
self
.
browser
.
contents
:
self
.
browser
.
_logger
.
debug
(
"Already logged in"
)
self
.
_logger
.
debug
(
"Already logged in"
)
# TODO: Perhaps zope.testbrowser should be patched instead?
# TODO: Perhaps zope.testbrowser should be patched instead?
self
.
browser
.
timer
.
start_time
=
self
.
browser
.
timer
.
end_time
=
0
self
.
browser
.
timer
.
start_time
=
self
.
browser
.
timer
.
end_time
=
0
return
return
self
.
browser
.
_logger
.
debug
(
"Logging in: username='%s', password='%s'"
%
\
self
.
_logger
.
debug
(
"Logging in: username='%s', password='%s'"
%
\
(
self
.
browser
.
_username
,
self
.
browser
.
_password
))
(
self
.
browser
.
_username
,
self
.
browser
.
_password
))
def
login
(
form
):
def
login
(
form
):
form
.
getControl
(
name
=
'__ac_name'
).
value
=
self
.
browser
.
_username
form
.
getControl
(
name
=
'__ac_name'
).
value
=
self
.
browser
.
_username
...
...
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