Skip to content

Instantly share code, notes, and snippets.

View weissjeffm's full-sized avatar

Jeff Weiss weissjeffm

View GitHub Profile
@weissjeffm
weissjeffm / anonymous-gist.
Created January 29, 2014 15:21
pytest trace
(cfme)[jweiss@localhost cfme_tests]$ py.test -k test_provider_edit
============================= test session starts ==============================
platform linux2 -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/home/jweiss/.virtualenvs/cfme/lib/python2.7/site-packages/_pytest/main.py", line 81, in wrap_session
INTERNALERROR> doit(config, session)
INTERNALERROR> File "/home/jweiss/.virtualenvs/cfme/lib/python2.7/site-packages/_pytest/main.py", line 117, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "/home/jweiss/.virtualenvs/cfme/lib/python2.7/site-packages/_pytest/core.py", line 377, in __call__
INTERNALERROR> return self._docall(methods, kwargs)
@weissjeffm
weissjeffm / anonymous-gist.py
Created January 31, 2014 14:48
error handler
from contextlib import contextmanager
import re
from functools import partial
@contextmanager
def handler(f):
try:
yield
except Exception as e:
if not f(e):
@weissjeffm
weissjeffm / error-session.py
Last active August 29, 2015 13:56
error handling
import utils.error as error
# when we expect an error but don't get one, we get an error that tells us so
with error.expected_regex("foo"):
pass
Truncated Traceback (Use C-c C-x to view full TB):
/home/jweiss/workspace/cfme_tests/utils/error.py in expected(f)
62 try:
63 yield
@weissjeffm
weissjeffm / chargeback.py
Created February 11, 2014 15:50
nav dest names
import cfme.web_ui.accordion as accordion
import cfme.web_ui.menu # to load menu nav
from functools import partial
import ui_navigate as nav
rates_page = __name__ + ".rates"
assignments_page = __name__ + ".assignments"
nav.add_branch('chargeback',
{rates_page: partial(accordion.click, "Rates"),
diff --git a/cfme/web_ui/flash.py b/cfme/web_ui/flash.py
index bb7c631..b48376d 100644
--- a/cfme/web_ui/flash.py
+++ b/cfme/web_ui/flash.py
@@ -5,6 +5,7 @@
from cfme.web_ui import Region
from selenium.webdriver.common.by import By
import cfme.fixtures.pytest_selenium as sel
+import itertools
diff --git a/cfme/web_ui/flash.py b/cfme/web_ui/flash.py
index bb7c631..0486c4b 100644
--- a/cfme/web_ui/flash.py
+++ b/cfme/web_ui/flash.py
@@ -5,6 +5,7 @@
from cfme.web_ui import Region
from selenium.webdriver.common.by import By
import cfme.fixtures.pytest_selenium as sel
+import itertools
class Region(object):
"""
Base class for all UI regions/pages
Args:
locators: A dict of locator objects for the given region
title: A string containing the title of the page
identifying_loc: Not sure
Usage:
import trace
t = trace.Trace()
x = 1
def foo():
x = x + 1
t.runfunc(foo)
Truncated Traceback (Use C-c C-x to view full TB):
<ipython-input-19-2c24c7f929de> in foo()
x=1
def foo(y):
x += 1
return x + y
foo(2)
Truncated Traceback (Use C-c C-x to view full TB):
<ipython-input-24-807bbe2ba12a> in foo(y)
1 x=1
2 def foo(y):
---------------------------------------------------------------------------
NoSuchElementException Traceback (most recent call last)
<ipython-input-138-4e38883c4768> in <module>()
1 import cfme.login as login
2 with trace_on([sel]):
----> 3 login.login("admin", "smartvm")
4
/home/jweiss/workspace/cfme_tests/cfme/login.pyc in login(username, password, submit_method)
68 # TODO: Should probably do the username check here, but there are pretty usernames to deal with