Skip to content

Commit

Permalink
Easier disabling of Table.LOCKING in add-on tests
Browse files Browse the repository at this point in the history
This commit allows the add-ons to set Table.LOCKING to False
independent of the order of imports.
  • Loading branch information
markotoplak committed Oct 1, 2021
1 parent ca91879 commit 83a10da
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Orange/canvas/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from Orange.data import Table

Table.LOCKING = True
if Table.LOCKING is None:
Table.LOCKING = True
9 changes: 8 additions & 1 deletion Orange/data/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,14 @@ def __init__(self, source, destination):

# noinspection PyPep8Naming
class Table(Sequence, Storage):
LOCKING = False

LOCKING = None
""" If the class attribute LOCKING is True, tables will throw exceptions
on in-place modifications unless unlocked explicitly. LOCKING is supposed
to be set to True for testing to help us find bugs. If set to False
or None, no safeguards are in place. Two different values are used for
the same behaviour to distinguish the unchanged default (None) form
explicit deactivation (False) that some add-ons might need. """

__file__ = None
name = "untitled"
Expand Down
3 changes: 2 additions & 1 deletion Orange/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import numpy as np
import Orange

Orange.data.Table.LOCKING = True
if Orange.data.Table.LOCKING is None:
Orange.data.Table.LOCKING = True


@contextmanager
Expand Down
4 changes: 2 additions & 2 deletions Orange/widgets/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import Orange
import Orange.widgets


Orange.data.Table.LOCKING = True
if Orange.data.Table.LOCKING is None:
Orange.data.Table.LOCKING = True


def load_tests(loader, tests, pattern):
Expand Down

0 comments on commit 83a10da

Please sign in to comment.