Passed
Push — master ( 0b984b...b1484e )
by Daniel
01:36
created

create_receiver_function()   A

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
1
import pytest
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
introduced by
Unable to import 'pytest'
Loading history...
2
3
4
def test_signal_registration(basicApp):
0 ignored issues
show
Coding Style Naming introduced by
The name basicApp does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
5
    plugin = basicApp.plugins.get("BasicPlugin")
6
    signals = plugin.signals.get()
7
    assert len(signals.keys()) == 1
8
    assert "test" in signals.keys()
9
10
11
def test_signal_send(basicApp):
0 ignored issues
show
Coding Style Naming introduced by
The name basicApp does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
12
    answers = basicApp.signals.send("test", basicApp, text="test")
13
    assert len(answers) == 1
14
    assert isinstance(answers, list)
15
    assert len(answers[0]) == 2
16
    assert isinstance(answers[0], tuple)
17
    assert answers[0][1] == {'text': 'test'}
18
19
20
def test_signal_connect(basicApp):
0 ignored issues
show
Coding Style Naming introduced by
The name basicApp does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
21
    def _test_command(plugin, **kwargs):
0 ignored issues
show
Unused Code introduced by
The argument plugin seems to be unused.
Loading history...
Unused Code introduced by
The argument kwargs seems to be unused.
Loading history...
22
        return "12345"
23
24
    plugin = basicApp.plugins.get("BasicPlugin")
25
    plugin.signals.connect("12345 receiver", "test", _test_command, "receiver 12345 for test")
26
    answers = plugin.signals.send("test")
27
    assert len(answers) == 2
28
    for answer in answers:
29
        if answer[0] == _test_command:
30
            assert answer[1] == "12345"
31
32
33
def test_signal_disconnect(basicApp):
0 ignored issues
show
Coding Style Naming introduced by
The name basicApp does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
34
    def _test_command(plugin, **kwargs):
0 ignored issues
show
Unused Code introduced by
The argument plugin seems to be unused.
Loading history...
Unused Code introduced by
The argument kwargs seems to be unused.
Loading history...
35
        return "12345"
36
37
    plugin = basicApp.plugins.get("BasicPlugin")
38
    plugin.signals.connect("12345 receiver", "test", _test_command, "receiver 12345 for test")
39
    answers = plugin.signals.send("test")
40
    assert len(answers) == 2
41
    for answer in answers:
42
        if answer[0] == _test_command:
43
            assert answer[1] == "12345"
44
45
    plugin.signals.disconnect("12345 receiver")
46
    answers = plugin.signals.send("test")
47
    assert len(answers) == 1
48
49
50
def test_receiver_get(basicApp):
0 ignored issues
show
Coding Style Naming introduced by
The name basicApp does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
51
    def _test_command(plugin, **kwargs):
0 ignored issues
show
Unused Code introduced by
The argument plugin seems to be unused.
Loading history...
Unused Code introduced by
The argument kwargs seems to be unused.
Loading history...
52
        return "12345"
53
54
    plugin = basicApp.plugins.get("BasicPlugin")
55
    receivers = plugin.signals.get_receiver()
56
    assert len(receivers) == 1  # test receiver
57
    plugin.signals.connect("12345 receiver", "test", _test_command, "receiver 12345 for test")
58
    receivers = plugin.signals.get_receiver()
59
    assert len(receivers) == 2
60
    plugin.deactivate()
61
    receivers = plugin.signals.get_receiver()
62
    assert len(receivers) == 0
0 ignored issues
show
Unused Code introduced by
Do not use len(SEQUENCE) as condition value
Loading history...
63
64
65
def test_multi_plugin_deactivations(basicApp, EmptyPlugin):
0 ignored issues
show
Coding Style Naming introduced by
The name basicApp does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
The name EmptyPlugin does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
66
    def test():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable test seems to be unused.
Loading history...
67
        pass
68
69
    plugin = basicApp.plugins.get("BasicPlugin")
70
    plugin2 = EmptyPlugin(app=basicApp, name="EmptyPlugin")
71
    plugin2.activate()
72
    assert plugin2.active is True
73
74
    plugin2.signals.register("test123", "test123 description")
75
    plugin2_signals = plugin2.signals.get()
76
    assert len(plugin2_signals) == 1
77
78
    plugin_signals = plugin.signals.get()
79
    # BasicPlugin has already registered a signal during init
80
    assert len(plugin_signals) == 1
81
82
    plugin2.deactivate()
83
    plugin2_signals = plugin2.signals.get()
84
    assert len(plugin2_signals) == 0
0 ignored issues
show
Unused Code introduced by
Do not use len(SEQUENCE) as condition value
Loading history...
85
    assert plugin2.active is False
86
87
    assert len(plugin_signals) == 1
88
    assert plugin.active is True
89
90
91
def test_signal_handling(basicApp, EmptyPlugin):
0 ignored issues
show
Coding Style Naming introduced by
The name basicApp does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
The name EmptyPlugin does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
92
    from blinker import NamedSignal
0 ignored issues
show
introduced by
Unable to import 'blinker'
Loading history...
93
    from groundwork.signals import UnknownSignal
94
95
    def sig_reg_test(plugin, **kwargs):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument plugin seems to be unused.
Loading history...
Unused Code introduced by
The argument kwargs seems to be unused.
Loading history...
96
        return ["data_1", "data_2"]
97
98
    plugin1 = EmptyPlugin(app=basicApp, name="EmptyPlugin")
99
100
    # This creates a gw receiver and a blinker internal signal called "test"
101
    plugin1.signals.connect("sig_reg_receiver", "sig_reg_test", sig_reg_test, "receiver sig_reg for test")
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (106/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
102
103
    # Check the blinker internal registration
104
    signal_namespace = basicApp.signals._namespace
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _namespace was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
105
    assert "sig_reg_test" in signal_namespace.keys()
106
    test_signal = signal_namespace["sig_reg_test"]
107
    assert isinstance(test_signal, NamedSignal)
108
109
    # Check the gw registration
110
    plugin_signals = plugin1.signals.get()
111
    # This must be 0, because gw has not registered a signal, this was done in blinker only
112
    assert len(plugin_signals) == 0
0 ignored issues
show
Unused Code introduced by
Do not use len(SEQUENCE) as condition value
Loading history...
113
114
    app_signals = basicApp.signals.get()
115
    assert "sig_reg_test" not in app_signals.keys()
116
117
    # Check if signal sending throws an error (without a registered gw signal)
118
    with pytest.raises(UnknownSignal):
119
        plugin1.signals.send("sig_reg_test")
120
121
    # Check if gw has a registered receiver
122
    plugin_receivers = plugin1.signals.get_receiver()
123
    assert "sig_reg_receiver" in plugin_receivers.keys()
124
125
    # Register the missing gw signal
126
    plugin_signal = plugin1.signals.register("sig_reg_test", "signal for sig_reg_test")
127
    assert plugin_signal is not None
128
129
    # Recheck the gw registration
130
    plugin_signals = plugin1.signals.get()
131
    # This must be 1, because gw has registered a signal now
132
    assert len(plugin_signals) == 1
133
134
    # Sending should work now
135
    return_values = plugin1.signals.send("sig_reg_test")
136
    # Check if the receivers sends back needed data
137
    assert len(return_values) == 1
138
    assert return_values[0][1][0] == "data_1"
139
140
141
def test_signal_handling_via_plugins(basicApp, EmptyPlugin):
0 ignored issues
show
Coding Style Naming introduced by
The name test_signal_handling_via_plugins does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
The name basicApp does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
The name EmptyPlugin does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
142
    def sig_reg_test_1(plugin, **kwargs):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument plugin seems to be unused.
Loading history...
Unused Code introduced by
The argument kwargs seems to be unused.
Loading history...
143
        return ["data_1", "data_2"]
144
145
    def sig_reg_test_2(plugin, **kwargs):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument plugin seems to be unused.
Loading history...
Unused Code introduced by
The argument kwargs seems to be unused.
Loading history...
146
        return ["data_3", "data_4"]
147
148
    plugin_send = EmptyPlugin(app=basicApp, name="Plugin_send")
149
150
    plugin_receive_pre = EmptyPlugin(app=basicApp, name="Plugin_receive_pre")
151
    plugin_receive_post = EmptyPlugin(app=basicApp, name="Plugin_receive_post")
152
153
    plugin_receive_pre.activate()
154
    plugin_receive_pre.signals.connect("sig_reg_pre_receiver", "signal_test",
155
                                       sig_reg_test_1, "receiver signal_test for test")
156
157
    plugin_send.activate()
158
    plugin_send.signals.register("signal_test", "signal_test doc")
159
160
    return_values = plugin_send.signals.send("signal_test")
161
    assert len(return_values) == 1
162
163
    plugin_receive_post.activate()
164
    plugin_receive_post.signals.connect("sig_reg_post_receiver", "signal_test",
165
                                        sig_reg_test_2, "receiver signal_test for test")
166
167
    return_values = plugin_send.signals.send("signal_test")
168
    assert len(return_values) == 2
169
170
    # Send signal and check return vales
171
172
173
def test_multi_plugin_sending(basicApp, EmptyPlugin):
0 ignored issues
show
Coding Style Naming introduced by
The name basicApp does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
The name EmptyPlugin does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Comprehensibility introduced by
This function exceeds the maximum number of variables (17/15).
Loading history...
174
    """
175
    Nearly some test as "test_signal_handling_via_plugins", but with an adjustable amount of plugins for sending
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (112/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
176
    and receiving.
177
178
    Registers receivers before the signal gets registers itself and afterwards.
179
    Checks if all receivers get correctly called, if signal is send.
180
181
    This tests will normally fail, if Weaknamespace is used in groundwork/signals.py:
182
    from blinker import WeakNamespace as Namespace
183
184
    So use always Namespace and if need do clean ups on groundwork site.
185
    """
186
187
    amount_pre_plugins = 30
188
    amount_post_plugins = 10
189
    amount_send_plugins = 30
190
191
    def create_receiver_function(start):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
192
193
        def func_template(*args, **kwargs):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument args seems to be unused.
Loading history...
Unused Code introduced by
The argument kwargs seems to be unused.
Loading history...
194
            return ["data_{0}_A".format(start),
195
                    "data_{0}_B".format(start)]
196
197
        return func_template
198
199
    # PRE receivers
200
    plugin_receive_pre = []
201
    for i in range(0, amount_pre_plugins):
202
        plugin_receive_pre.append(EmptyPlugin(app=basicApp, name="Plugin_receive_pre_{0}".format(i)))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (101/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
203
        plugin_receive_pre[i].activate()
204
        plugin_receive_pre[i].signals.connect("sig_reg_pre_receiver_{0}".format(i), "signal_test",
205
                                              create_receiver_function(i),
206
                                              "receiver signal_test_{0} for test".format(i))
207
208
    # Count gw internal registered receivers
209
    amount = 0
210
    for receiver in basicApp.signals.receivers.keys():
211
        if "sig_reg_pre_receiver" in receiver:
212
            amount += 1
213
    assert amount == amount_pre_plugins
214
215
    # Senders
216
    plugin_send = []
217
    for i in range(0, amount_send_plugins):
218
        plugin_send.append(EmptyPlugin(app=basicApp, name="Plugin_send_{0}".format(i)))
219
        plugin_send[i].activate()
220
        if i == 0:
221
            # We only need to register our signal once
222
            plugin_send[0].signals.register("signal_test", "signal_test")
223
            assert amount_pre_plugins == len(basicApp.signals.signals["signal_test"]._signal.receivers)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (103/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style Best Practice introduced by
It seems like _signal was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
224
225
    # Check, if for our signal all receivers have been registered
226
    print("Registered receivers for signal_test: {0}".format(
227
        len(basicApp.signals.signals["signal_test"]._signal.receivers)))
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _signal was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
228
    assert amount_pre_plugins == len(basicApp.signals.signals["signal_test"]._signal.receivers)
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _signal was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
229
230
    # Send signal
231
    for index, plugin in enumerate(plugin_send):
232
        print(" {0} sending...".format(index))
233
        return_values = plugin.signals.send("signal_test")
234
235
        # check return length and content
236
        assert len(return_values) == amount_pre_plugins
237
        for i in range(0, amount_pre_plugins):
238
            found = False
239
            for value in return_values:
240
                if value[1][0] == "data_{0}_A".format(i) and value[1][1] == "data_{0}_B".format(i):
241
                    found = True
242
                    break
243
            assert found is True
244
245
    # Register POST receivers
246
    plugin_receive_post = []
247
    for i in range(0, amount_post_plugins):
248
        plugin_receive_post.append(EmptyPlugin(app=basicApp, name="Plugin_receive_post_{0}".format(i)))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (103/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
249
        plugin_receive_post[i].activate()
250
        plugin_receive_post[i].signals.connect("sig_reg_post_receiver_{0}".format(i), "signal_test",
251
                                               create_receiver_function(amount_pre_plugins + i),
252
                                               "receiver signal_test_{0} for test".format(i))
253
254
    # Send again a signal and check return values
255
    # Send signal
256
    for index, plugin in enumerate(plugin_send):
257
        print(" {0} sending again...".format(index))
258
        return_values = plugin.signals.send("signal_test")
259
260
        # check return length and content
261
        assert len(return_values) == amount_pre_plugins + amount_post_plugins
262
        for i in range(0, amount_pre_plugins + amount_post_plugins):
263
            found = False
264
            for value in return_values:
265
                if value[1][0] == "data_{0}_A".format(i) and value[1][1] == "data_{0}_B".format(i):
266
                    found = True
267
                    break
268
            assert found is True
269