Skip to content

Commit

Permalink
test_{samples,calculator}.py: migrate from nose to pytest.
Browse files Browse the repository at this point in the history
Description: nose is an obsoleted testing framework for Python, dead
  and unmaintained since 2015

Properly teardown fixtures after the test.

Reference: https://bugs.debian.org/1018659
Reference: https://bugs.gentoo.org/878727
Reference: uvemas#114
  • Loading branch information
Benda Xu committed Feb 1, 2023
1 parent d7dcbb6 commit b9a7a3d
Show file tree
Hide file tree
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
Expand Down Expand Up @@ -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:])

Expand Down Expand Up @@ -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."""
Expand Down
Empty file.
24 changes: 0 additions & 24 deletions vitables/calculator/test/test_calculator.py

This file was deleted.

0 comments on commit b9a7a3d

Please sign in to comment.