Skip to content

Commit

Permalink
in the middle of trying to fix nosetests (no more failures including …
Browse files Browse the repository at this point in the history
…tests in ignore_these, but tests take >1000s
  • Loading branch information
leo10tt10 committed Aug 24, 2017
1 parent 9d753f6 commit 3279bd6
Show file tree
Hide file tree
Showing 31 changed files with 235 additions and 189 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions pyrpl/test/debug_timer.py → ignore_these/debug_timer.py
@@ -1,11 +1,11 @@
from qtpy import QtCore, QtWidgets
import time
from ..async_utils import sleep as async_sleep
from pyrpl.async_utils import sleep as async_sleep

""" what is this file for? delete it? """

if False:
from .. import Pyrpl
from pyrpl import Pyrpl

pyrpl = Pyrpl(config="nosetests_source.yml",
source="nosetests_config.yml")
Expand Down
@@ -1,11 +1,11 @@
import logging
logger = logging.getLogger(name=__name__)
import numbers
from ..modules import Module
from ..attributes import BoolProperty, FilterProperty, SelectProperty, \
from pyrpl.modules import Module
from pyrpl.attributes import BoolProperty, FilterProperty, SelectProperty, \
FloatProperty
from ..module_attributes import ModuleProperty
from .test_base import TestPyrpl
from pyrpl.module_attributes import ModuleProperty
from pyrpl.test.test_base import TestPyrpl


class MyFilterProperty(FilterProperty):
Expand Down
File renamed without changes.
Expand Up @@ -4,7 +4,7 @@
import numpy as np
from time import sleep
from qtpy import QtCore, QtWidgets
from ..test_base import TestPyrpl
from pyrpl.test.test_base import TestPyrpl


class TestInput(TestPyrpl):
Expand Down
@@ -1,8 +1,8 @@
import logging
logger = logging.getLogger(name=__name__)
from ...attributes import *
from ... import CurveDB
from ..test_base import TestPyrpl
from pyrpl.attributes import *
from pyrpl import CurveDB
from pyrpl.test.test_base import TestPyrpl


class TestIir(TestPyrpl):
Expand All @@ -12,6 +12,9 @@ def setup(self):
self.pyrpl.na = self.pyrpl.networkanalyzer
self.na = self.pyrpl.networkanalyzer

def teardown(self):
self.na.stop()

def test_pz_interface(self):
""" tests that poles and real/comples_poles remain sync'ed"""
iir = self.pyrpl.rp.iir
Expand Down Expand Up @@ -66,6 +69,7 @@ def test_iirsimple_na_generator(self):
points=301,
rbw=[500, 500],
average_per_point=1,
running_state='stopped',
trace_average=1,
amplitude=0.005,
input=iir,
Expand Down Expand Up @@ -143,6 +147,7 @@ def test_iircomplicated_na_generator(self):
points=501,
rbw=[500, 500],
average_per_point=1,
running_state='stopped',
trace_average=1,
amplitude=0.05,
input=iir,
Expand All @@ -162,6 +167,7 @@ def test_iircomplicated_na_generator(self):
points=301,
rbw=[500, 500],
average_per_point=1,
running_state='stopped',
trace_average=1,
amplitude=0.05,
input=iir,
Expand Down Expand Up @@ -190,6 +196,7 @@ def test_iircomplicated_na_generator(self):
points=2501,
rbw=[1000, 1000],
average_per_point=5,
running_state='stopped',
trace_average=1,
amplitude=0.02,
input=iir,
Expand All @@ -213,6 +220,7 @@ def test_iircomplicated_na_generator(self):
points=301,
rbw=1000,
average_per_point=1,
running_state='stopped',
trace_average=1,
amplitude=0.01,
input='iir',
Expand Down
@@ -1,8 +1,8 @@
import logging
logger = logging.getLogger(name=__name__)
from ...attributes import *
from ... import CurveDB
from ..test_base import TestPyrpl
from pyrpl.attributes import *
from pyrpl import CurveDB
from pyrpl.test.test_base import TestPyrpl


class TestPidNaIq(TestPyrpl):
Expand All @@ -12,6 +12,9 @@ def setup(self):
self.pyrpl.na = self.pyrpl.networkanalyzer
self.na = self.pyrpl.networkanalyzer

def teardown(self):
self.na.stop()

def test_na(self):
error_threshold = 0.03 # (relative error, dominated by phase error)
if self.r is None:
Expand Down
34 changes: 34 additions & 0 deletions ignore_these/test_hardware_modules/test_sampler.py
@@ -0,0 +1,34 @@
import logging
logger = logging.getLogger(name=__name__)
from pyrpl.test.test_base import TestPyrpl


class TestInput(TestPyrpl):
def setup(self):
self.p = self.pyrpl
self.sampler = self.r.sampler

def teardown(self):
pass

def test_sampler(self):
with self.pyrpl.asgs.pop('test_sampler') as asg:
asg.setup(amplitude=0.5,
offset = 0.1,
frequency=500e3,
waveform='sin',
output_direct='off',
trigger_source='immediately')
# test sample function
sample = getattr(self.sampler, asg.name)
assert sample >= asg.offset - asg.amplitude, sample
assert sample <= asg.offset + asg.amplitude, sample
# test stats function
mean, std, max, min = self.sampler.stats(asg.name, t=1.0)
assert min <= mean, (mean, std, max, min)
assert mean <= max, (mean, std, max, min)
assert std <= (max-min)/2.0, (mean, std, max, min, (max-min)/2.0)
assert max <= asg.offset + asg.amplitude, (mean, std, max, min, asg.offset + asg.amplitude)
# needs a small margin to work properly because of rounding off towards negative values in asg
assert min + 2.0**(-14) >= asg.offset - asg.amplitude, \
(mean, std, max, min, min + 2.0**(-14), asg.offset - asg.amplitude)
Expand Up @@ -2,11 +2,11 @@
logger = logging.getLogger(name=__name__)
import time
import numpy as np
from ...async_utils import sleep as async_sleep
from pyrpl.async_utils import sleep as async_sleep
from qtpy import QtCore, QtWidgets
from ..test_base import TestPyrpl
from ... import APP
from ...curvedb import CurveDB
from pyrpl.test.test_base import TestPyrpl
from pyrpl import APP
from pyrpl.curvedb import CurveDB

class TestScope(TestPyrpl):
"""
Expand Down Expand Up @@ -151,18 +151,12 @@ def test_no_write_in_config(self):
"""
# first, check whether something else is writing continuously to
# config file
return
self.pyrpl.rp.scope.stop()
for i in range(10):
async_sleep(0.1)
#APP.processEvents()
async_sleep(1.0)
old = self.pyrpl.c._save_counter
for i in range(10):
async_sleep(0.1)
#APP.processEvents()
async_sleep(1.0)
new = self.pyrpl.c._save_counter
assert (old == new), (old, new, "scope is not the reason")

# next, check whether the scope does this
for rolling_mode in (True, False):
self.pyrpl.rp.scope.setup(duration=0.005,
Expand All @@ -173,19 +167,15 @@ def test_no_write_in_config(self):
rolling_mode=True,
trace_average=1,
running_state="running_continuous")

old = self.pyrpl.c._save_counter
for i in range(10):
async_sleep(0.1)
# APP.processEvents()
new = self.pyrpl.c._save_counter

self.pyrpl.rp.scope.stop()
assert(old==new), (old, new, "scope is the problem", rolling_mode)

def test_save_curve_old(self):
if self.r is None:
return
self.r.scope.setup(duration=0.01,
trigger_source='immediately',
trigger_delay=0.,
Expand Down
Expand Up @@ -2,8 +2,8 @@
logger = logging.getLogger(name=__name__)
import time
import numpy as np
from ... import CurveDB
from ..test_base import TestPyrpl
from pyrpl import CurveDB
from pyrpl.test.test_base import TestPyrpl


class TestScopeAsgAms(TestPyrpl):
Expand Down
Expand Up @@ -4,7 +4,7 @@
import numpy as np
from time import sleep
from qtpy import QtCore, QtWidgets
from ..test_base import TestPyrpl
from pyrpl.test.test_base import TestPyrpl


class TestScope(TestPyrpl):
Expand Down
@@ -1,8 +1,8 @@
import logging
logger = logging.getLogger(name=__name__)
from qtpy import QtWidgets
from .test_base import TestPyrpl
from ..software_modules.module_managers import ModuleManager
from pyrpl.test.test_base import TestPyrpl
from pyrpl.software_modules.module_managers import ModuleManager


class TestOwnership(TestPyrpl):
Expand Down
@@ -1,10 +1,10 @@
import logging
logger = logging.getLogger(name=__name__)
from ..modules import Module
from ..attributes import FloatProperty, SelectProperty, ProxyProperty
from ..module_attributes import *
from ..memory import MemoryTree
from ..async_utils import sleep
from pyrpl.modules import Module
from pyrpl.attributes import FloatProperty, SelectProperty, ProxyProperty
from pyrpl.module_attributes import *
from pyrpl.memory import MemoryTree
from pyrpl.async_utils import sleep


class MySubModule(Module):
Expand Down
Expand Up @@ -3,7 +3,7 @@
import logging
logger = logging.getLogger(name=__name__)
import os
from .. import Pyrpl, RedPitaya, user_config_dir
from pyrpl import Pyrpl, RedPitaya, user_config_dir


class TestRedpitaya(object):
Expand Down
@@ -1,8 +1,8 @@
import logging
logger = logging.getLogger(name=__name__)
from ..modules import Module
from ..attributes import *
from ..test.test_redpitaya import TestRedpitaya
from pyrpl.modules import Module
from pyrpl.attributes import *
from ignore_these import TestRedpitaya


class TestRegisters(TestRedpitaya):
Expand Down
Expand Up @@ -3,12 +3,16 @@
import numpy as np
from time import sleep
from qtpy import QtCore, QtWidgets
from .test_base import TestPyrpl
from .. import APP
from pyrpl.test.test_base import TestPyrpl
from pyrpl import APP


class TestClass(TestPyrpl):

def teardown(self):
""" make 100% sure that specan has stopped """
self.pyrpl.spectrumanalyzer.stop()

def test_specan_stopped_at_startup(self):
"""
This was so hard to detect, I am making a unit test
Expand All @@ -25,7 +29,6 @@ def test_no_write_in_config(self):
self.pyrpl.spectrumanalyzer.setup_attributes = dict(span=1e5,
input="out1",
running_state='running_continuous')

old = self.pyrpl.c._save_counter
for i in range(10):
sleep(0.01)
Expand Down
Empty file.
Expand Up @@ -2,17 +2,17 @@
logger = logging.getLogger(name=__name__)
import time
import numpy as np
from ...async_utils import sleep as async_sleep
from pyrpl.async_utils import sleep as async_sleep
from qtpy import QtCore, QtWidgets
from ..test_base import TestPyrpl
from ... import APP
from ...curvedb import CurveDB
from ...widgets.startup_widget import HostnameSelectorWidget
from ...async_utils import sleep
from ...widgets.spinbox import NumberSpinBox
from ...widgets.attribute_widgets import NumberAttributeWidget
from ...hardware_modules.iir import IIR
from ...software_modules import NetworkAnalyzer
from pyrpl.test.test_base import TestPyrpl
from pyrpl import APP
from pyrpl.curvedb import CurveDB
from pyrpl.widgets.startup_widget import HostnameSelectorWidget
from pyrpl.async_utils import sleep as async_sleep
from pyrpl.widgets.spinbox import NumberSpinBox
from pyrpl.widgets.attribute_widgets import NumberAttributeWidget
from pyrpl.hardware_modules.iir import IIR
from pyrpl.software_modules import NetworkAnalyzer

from qtpy import QtTest, QtCore

Expand All @@ -36,7 +36,7 @@ def test_spin_box(self):
_TEST_SPINBOX_BUTTON_DOWN_TIME = 0.05

def assert_spin_box(self, mod, widget, name, aw):
print("Testing widget for %s.%s..." %(mod.name, name))
print("Testing spinbox widget for %s.%s..." %(mod.name, name))
# make sure the module is not reserved by some other module
# (as this would disable the key press response)
mod.free()
Expand Down Expand Up @@ -64,14 +64,16 @@ def assert_spin_box(self, mod, widget, name, aw):

# go up
QtTest.QTest.keyPress(aw, QtCore.Qt.Key_Up)
sleep(self._TEST_SPINBOX_BUTTON_DOWN_TIME)
async_sleep(self._TEST_SPINBOX_BUTTON_DOWN_TIME)
QtTest.QTest.keyRelease(aw, QtCore.Qt.Key_Up)
async_sleep(self._TEST_SPINBOX_BUTTON_DOWN_TIME)
new_val = getattr(mod, name)
assert(new_val > m_value), (new_val, m_value, mod.name, name)

# go down
QtTest.QTest.keyPress(aw, QtCore.Qt.Key_Down)
sleep(self._TEST_SPINBOX_BUTTON_DOWN_TIME)
async_sleep(self._TEST_SPINBOX_BUTTON_DOWN_TIME)
QtTest.QTest.keyRelease(aw, QtCore.Qt.Key_Down)
async_sleep(self._TEST_SPINBOX_BUTTON_DOWN_TIME)
new_new_val = getattr(mod, name)
assert (new_new_val < new_val), (new_new_val, new_val, mod.name, name)
12 changes: 12 additions & 0 deletions ignore_these/test_widgets/test_module_widgets.py
@@ -0,0 +1,12 @@
import logging
logger = logging.getLogger(name=__name__)
import time
import numpy as np
from pyrpl.async_utils import sleep as async_sleep
from qtpy import QtCore, QtWidgets
from pyrpl.test.test_base import TestPyrpl
from pyrpl import APP
from pyrpl.curvedb import CurveDB

class TestModuleWidgets(TestPyrpl):
OPEN_ALL_DOCKWIDGETS = True # forces all DockWidgets to become visible
Expand Up @@ -2,13 +2,13 @@
logger = logging.getLogger(name=__name__)
import time
import numpy as np
from ...async_utils import sleep as async_sleep
from pyrpl.async_utils import sleep as async_sleep
from qtpy import QtCore, QtWidgets
from ..test_base import TestPyrpl
from ... import APP
from ...curvedb import CurveDB
from ...widgets.startup_widget import HostnameSelectorWidget
from ...async_utils import sleep
from pyrpl.test.test_base import TestPyrpl
from pyrpl import APP
from pyrpl.curvedb import CurveDB
from pyrpl.widgets.startup_widget import HostnameSelectorWidget
from pyrpl.async_utils import sleep

class TestStartupWidgets(TestPyrpl):
# somehow the file seems to suffer from other nosetests, so pick an
Expand Down

0 comments on commit 3279bd6

Please sign in to comment.