Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for pystone as Python 3.7 dropped pystone. #50

Merged
merged 1 commit into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ CHANGES

- Drop support for Python 3.3 and 3.4.

- Drop support for pystone as Python 3.7 dropped pystone. So
``Browser.lastRequestPystones`` no longer exists. Rename
``.browser.PystoneTimer`` to ``.browser.Timer``.

- Fix ``mechRepr`` of CheckboxListControl to always return a native str.
(https://github.com/zopefoundation/zope.testbrowser/pull/46).

Expand Down
5 changes: 1 addition & 4 deletions docs/narrative.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1632,16 +1632,13 @@ Performance Testing

Browser objects keep up with how much time each request takes. This can be
used to ensure a particular request's performance is within a tolerable range.
Be very careful using raw seconds, cross-machine differences can be huge,
pystones is usually a better choice.
Be very careful using raw seconds, cross-machine differences can be huge.

.. doctest::

>>> browser.open('http://localhost/@@/testbrowser/simple.html')
>>> browser.lastRequestSeconds < 10 # really big number for safety
True
>>> browser.lastRequestPystones < 10000 # really big number for safety
True


Handling Errors
Expand Down
29 changes: 2 additions & 27 deletions src/zope/testbrowser/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Browser(SetattrErrorsMixin):
__html = None

def __init__(self, url=None, wsgi_app=None):
self.timer = PystoneTimer()
self.timer = Timer()
self.raiseHttpErrors = True
self.handleErrors = True

Expand Down Expand Up @@ -170,11 +170,6 @@ def isHtml(self):
"""See zope.testbrowser.interfaces.IBrowser"""
return self._response and 'html' in self._response.content_type

@property
def lastRequestPystones(self):
"""See zope.testbrowser.interfaces.IBrowser"""
return self.timer.elapsedPystones

@property
def lastRequestSeconds(self):
"""See zope.testbrowser.interfaces.IBrowser"""
Expand Down Expand Up @@ -1401,21 +1396,9 @@ def isMatching(string, expr):
return normalizeWhitespace(expr) in normalizeWhitespace(string)


class PystoneTimer(object):
class Timer(object):
start_time = 0
end_time = 0
_pystones_per_second = None

@property
def pystonesPerSecond(self):
"""How many pystones are equivalent to one second on this machine"""

# deferred import as workaround for Zope 2 testrunner issue:
# http://www.zope.org/Collectors/Zope/2268
from test import pystone
if self._pystones_per_second is None:
self._pystones_per_second = pystone.pystones(pystone.LOOPS//10)[1]
return self._pystones_per_second

def _getTime(self):
if sys.platform.startswith('win'):
Expand Down Expand Up @@ -1447,14 +1430,6 @@ def elapsedSeconds(self):
end_time = self.end_time
return end_time - self.start_time

@property
def elapsedPystones(self):
"""Elapsed pystones in timing period

See elapsed_seconds for definition of timing period.
"""
return self.elapsedSeconds * self.pystonesPerSecond

def __enter__(self):
self.start()

Expand Down
11 changes: 0 additions & 11 deletions src/zope/testbrowser/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,6 @@ def getLink(text=None, url=None, id=None, index=0):
required=True,
readonly=True)

lastRequestPystones = zope.schema.Field(
title=u"Approximate System-Independent Effort of Last Request "
u"(Pystones)",
description=(u"""Return how many pystones the last request took.

This number is found by multiplying the number of pystones/second at
which this system benchmarks and the result of ``lastRequestSeconds``.
"""),
required=True,
readonly=True)

def getControl(label=None, name=None, index=None):
"""Get a control from the page.

Expand Down