Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_{samples,calculator}.py: migrate from nose to pytest.
Browse files Browse the repository at this point in the history
nose is an obsoleted testing framework for Python, dead and
unmaintained since 2015.

Properly teardown fixtures after the tests.

Reference: https://bugs.debian.org/1018659
Reference: https://bugs.gentoo.org/878727
Closes: uvemas#114
Benda Xu committed Feb 1, 2023
1 parent d98ea6d commit 74d68a4
Showing 4 changed files with 22 additions and 31 deletions.
15 changes: 15 additions & 0 deletions tests/test_calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import vitables.calculator.calculator as vtc


class TestCalculator:
"""Test calculator functionality."""

def test_extract_identifiers(self):
"""Test function that extract marked identifiers from an expression."""
empty_set = vtc.extract_identifiers('')
assert len(empty_set) == 0
assert set(['$data']) == vtc.extract_identifiers('$data')
assert set(['$data']) == vtc.extract_identifiers('+$data*')
assert set(['$data']) == vtc.extract_identifiers('+$data*$data')
assert set(['$data', '$data1']) == vtc.extract_identifiers('+$data*$data1 + test')
assert set(['$data', '$test.data1']) == vtc.extract_identifiers('+$data*$test.data1 + test')
14 changes: 7 additions & 7 deletions vitables/test/test_samples.py → tests/test_samples.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import sys
import os.path
import nose.tools as nt

import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)

from qtpy import QtWidgets
from qtpy import QtCore
@@ -40,7 +35,7 @@ def assert_path(test, path):
if not path:
return
index = get_index(test.model, path[0])
nt.assert_false(index is None)
assert index is not None
test.view.activateNode(index)
assert_path(test, path[1:])

@@ -182,11 +177,16 @@ def setup_class(cls):
cls.model = cls.vtgui.dbs_tree_model
cls.view = cls.vtgui.dbs_tree_view

@classmethod
def teardown_class(cls):
del cls.vtapp
del cls.app

def test_opening_files(self):
"""Generate tests for given data files."""
for filepath, nodes in self.TEST_NODES.items():
for node in nodes:
yield self.check_node_open, filepath, node
self.check_node_open(filepath, node)

def check_node_open(self, filepath, nodepath):
"""Open file get access to a node and read all cells."""
Empty file.
24 changes: 0 additions & 24 deletions vitables/calculator/test/test_calculator.py

This file was deleted.

0 comments on commit 74d68a4

Please sign in to comment.