1- # This code is derived from the conftest.py file from the ezomero library,
2- # which is licensed under the GNU General Public License v2.0 as published by
3- # the Free Software Foundation.
1+ # This code is derived from the conftest.py file in the ezomero project:
2+ # https://github.com/erickmartins/ezomero
3+ # Copyright (c) 2020-2025, Erick Ratamero, Dave Mellert, and contributors
44#
5- # Copyright (c) 2020-2025, Erick Ratamero, Dave Mellert, and contributors
6- #
7- # This program is free software: you can redistribute it and/or modify
8- # it under the terms of the GNU General Public License as published by
9- # the Free Software Foundation, either version 3 of the License, or
10- # (at your option) any later version.
11- #
12- # This program is distributed in the hope that it will be useful,
13- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- # GNU General Public License for more details.
16- #
17- # For the original code, please see:
18- # https://github.com/erickmartins/ezomero
5+ # ezomero is distributed under the GNU General Public License, version 2
6+ # (GPL-2.0). napari-omero is GPL-2.0-or-later, which is compatible. This file is
7+ # distributed under the same terms; it comes with NO WARRANTY, to the extent
8+ # permitted by law. See the GNU General Public License for more details.
199#
2010# Note that these fixtures are only used for the OMERO server tests.
2111import os
3525DEFAULT_OMERO_HOST = "localhost"
3626DEFAULT_OMERO_WEB_HOST = "http://localhost:4080"
3727DEFAULT_OMERO_PORT = "4064"
38- DEFAULT_OMERO_SECURE = 1
28+ DEFAULT_OMERO_SECURE = True
3929
4030# [[group, permissions], ...]
4131GROUPS_TO_CREATE = [["test_group_1" , "read-only" ], ["test_group_2" , "read-only" ]]
@@ -77,7 +67,7 @@ def pytest_addoption(parser):
7767 parser .addoption (
7868 "--omero-secure" ,
7969 action = "store" ,
80- default = bool ( os .environ .get ("OMERO_SECURE" , DEFAULT_OMERO_SECURE ) ),
70+ default = os .environ .get ("OMERO_SECURE" , DEFAULT_OMERO_SECURE ),
8171 )
8272
8373
@@ -89,7 +79,14 @@ def omero_params(request):
8979 host = request .config .getoption ("--omero-host" )
9080 web_host = request .config .getoption ("--omero-web-host" )
9181 port = request .config .getoption ("--omero-port" )
92- secure = request .config .getoption ("--omero-secure" )
82+ secure_opt = request .config .getoption ("--omero-secure" )
83+ # the option default is a real bool, but an OMERO_SECURE env var arrives as
84+ # a string ("0"/"false" should mean False), so coerce explicitly.
85+ secure = (
86+ secure_opt
87+ if isinstance (secure_opt , bool )
88+ else str (secure_opt ).strip ().lower () in ("1" , "true" , "yes" )
89+ )
9390 return (user , password , host , web_host , port , secure )
9491
9592
@@ -205,7 +202,7 @@ def users_groups(conn, omero_params):
205202
206203@pytest .fixture (scope = "session" )
207204def conn (omero_params ):
208- user , password , host , web_host , port , secure = omero_params
205+ user , password , host , _web_host , port , secure = omero_params
209206 conn = BlitzGateway (user , password , host = host , port = port , secure = secure )
210207 conn .connect ()
211208 yield conn
0 commit comments