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

Integration tests: call pytest directly #85

Merged
merged 3 commits into from
Feb 28, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,8 @@
#
#
import os
import sys

from setuptools import setup
from setuptools.command.test import test as test_command


class PyTest(test_command):
user_options = [
('test-path=', 't', "base dir for test collection"),
('test-ice-config=', 'i',
"use specified 'ice config' file instead of default"),
('test-pythonpath=', 'p', "prepend 'pythonpath' to PYTHONPATH"),
('test-string=', 'k', "only run tests matching 'string'"),
('test-marker=', 'm', "only run tests including 'marker'"),
('test-no-capture', 's', "don't suppress test output"),
('test-failfast', 'x', "Exit on first error"),
('test-verbose', 'v', "more verbose output"),
('test-quiet', 'q', "less verbose output"),
('junitxml=', None, "create junit-xml style report file at 'path'"),
('pdb', None, "fallback to pdb on error"),
]

def initialize_options(self):
test_command.initialize_options(self)
self.test_pythonpath = None
self.test_string = None
self.test_marker = None
self.test_path = 'test'
self.test_failfast = False
self.test_quiet = False
self.test_verbose = False
self.test_no_capture = False
self.junitxml = None
self.pdb = False
self.test_ice_config = None

def finalize_options(self):
test_command.finalize_options(self)
self.test_args = [self.test_path]
if self.test_string is not None:
self.test_args.extend(['-k', self.test_string])
if self.test_marker is not None:
self.test_args.extend(['-m', self.test_marker])
if self.test_failfast:
self.test_args.extend(['-x'])
if self.test_verbose:
self.test_args.extend(['-v'])
if self.test_quiet:
self.test_args.extend(['-q'])
if self.junitxml is not None:
self.test_args.extend(['--junitxml', self.junitxml])
if self.pdb:
self.test_args.extend(['--pdb'])
self.test_suite = True
if 'ICE_CONFIG' not in os.environ:
os.environ['ICE_CONFIG'] = self.test_ice_config

def run_tests(self):
if self.test_pythonpath is not None:
sys.path.insert(0, self.test_pythonpath)
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)


def read(fname):
Expand Down Expand Up @@ -122,9 +60,7 @@ def read(fname):
zip_safe=True,
download_url='%s/v%s.tar.gz' % (url, version),
keywords=['OMERO.CLI', 'plugin'],
cmdclass={'test': PyTest},
install_requires=[
'future',
'omero-py>=5.6.0',
'PyYAML',
'jinja2',
Expand Down
7 changes: 1 addition & 6 deletions src/omero_metadata/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@
Use is subject to license terms supplied in LICENSE.txt

"""
from __future__ import division

import omero_ext.argparse as argparse
from builtins import str
from builtins import range
from builtins import object
from future.utils import native_str
import logging
import mimetypes
import os
Expand Down Expand Up @@ -734,5 +729,5 @@ def pixelsize(self, args):
pixel.setPhysicalSizeZ(omero.model.LengthI(args.z, unit))

group_id = pixels[0].getDetails().getGroup().getId().getValue()
ctx = {'omero.group': native_str(group_id)}
ctx = {'omero.group': str(group_id)}
conn.getUpdateService().saveArray(pixels, ctx)
19 changes: 6 additions & 13 deletions src/omero_metadata/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
Populate bulk metadata tables from delimited text files.
"""
from __future__ import print_function

#
# Copyright (C) 2011-2019 University of Dundee. All rights reserved.
Expand All @@ -24,12 +23,6 @@
#


from builtins import chr
from builtins import str
from builtins import range
from future.utils import native_str
from past.builtins import basestring
from builtins import object
import logging
import gzip
import sys
Expand Down Expand Up @@ -1197,7 +1190,7 @@ def create_table(self):
group = str(self.value_resolver.target_group)
sr = sf.sharedResources()
table = sr.newTable(1, self.table_name,
{'omero.group': native_str(group)})
{'omero.group': str(group)})
if table is None:
raise MetadataError(
"Unable to create table: %s" % DEFAULT_TABLE_NAME)
Expand Down Expand Up @@ -1235,7 +1228,7 @@ def preprocess_data(self, reader):
break
try:
log.debug("Value's class: %s" % value.__class__)
if isinstance(value, basestring):
if isinstance(value, str):
column.size = max(
column.size, len(value.encode('utf-8')))
# The following IDs are needed for
Expand Down Expand Up @@ -1339,7 +1332,7 @@ def create_file_annotation(self, table):
link = self.create_annotation_link()
link.parent = self.target_object
link.child = file_annotation
update_service.saveObject(link, {'omero.group': native_str(group)})
update_service.saveObject(link, {'omero.group': str(group)})

def populate(self, rows):
nrows = len(rows)
Expand Down Expand Up @@ -1602,7 +1595,7 @@ def projection(self, q, ids, nss=None, batch_size=None):
nids = 1
single_id = ids

if isinstance(nss, basestring):
if isinstance(nss, str):
params.addString("ns", nss)
elif nss:
params.map['nss'] = rlist(rstring(s) for s in nss)
Expand Down Expand Up @@ -1804,7 +1797,7 @@ def _save_annotation_links(self, links):
group = str(self.target_object.details.group.id)
update_service = sf.getUpdateService()
arr = update_service.saveAndReturnArray(
links, {'omero.group': native_str(group)})
links, {'omero.group': str(group)})
return arr

def _save_annotation_and_links(self, links, ann, batch_size):
Expand All @@ -1829,7 +1822,7 @@ def _save_annotation_and_links(self, links, ann, batch_size):
for link in batch:
link.setChild(annobj)
update_service.saveArray(
batch, {'omero.group': native_str(group)})
batch, {'omero.group': str(group)})
sz += len(batch)
return sz

Expand Down
8 changes: 4 additions & 4 deletions test/integration/clitest/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import pytest
from past.builtins import long

import omero
import omero.gateway
Expand All @@ -43,7 +42,7 @@ def setup_method(self, method):

conn = BlitzGateway(client_obj=self.client)
self.imageid = unwrap(self.image.getId())
assert isinstance(self.imageid, long)
assert isinstance(self.imageid, int)
wrapper = conn.getObject("Image", self.imageid)
self.md = Metadata(wrapper)

Expand Down Expand Up @@ -245,9 +244,10 @@ def test_deletebulkanns(self, capfd):
o = self.invoke(capfd)
assert "FileAnnotation:" in o

# Should have no FileAnnotation since it's deleted
# Should be empty since it's deleted
o = self.invoke(capfd)
assert "FileAnnotation:" not in o
assert o == ""
assert len(o.strip()) == 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 2nd assert seems redundant since you're already checked that o == ""?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests have been restored to their previous state before cd4f657 but I agree the second assert feels likely superfluous and could be pushed away if we wish so


@pytest.mark.parametrize('report', [False, True])
def test_measures(self, capfd, report):
Expand Down
4 changes: 0 additions & 4 deletions test/integration/metadata/test_populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
and populate_roi.py scripts.
"""

from builtins import str
from builtins import zip
from builtins import range
from builtins import object
from omero.testlib import ITest
import string
import csv
Expand Down
1 change: 0 additions & 1 deletion test/integration/tablestest/test_populate_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

"""

from builtins import range
from omero.testlib import ITest
import os

Expand Down
Loading