pytest-mqtt 0.6.2.dev0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-mqtt
3
- Version: 0.6.2.dev0
3
+ Version: 0.7.0
4
4
  Summary: pytest-mqtt supports testing systems based on MQTT
5
5
  Author-email: Andreas Motl <andreas.motl@panodata.org>, Richard Pobering <richard.pobering@panodata.org>
6
6
  Project-URL: changelog, https://github.com/mqtt-tools/pytest-mqtt/blob/main/CHANGES.rst
@@ -31,6 +31,7 @@ Classifier: Programming Language :: Python :: 3.10
31
31
  Classifier: Programming Language :: Python :: 3.11
32
32
  Classifier: Programming Language :: Python :: 3.12
33
33
  Classifier: Programming Language :: Python :: 3.13
34
+ Classifier: Programming Language :: Python :: 3.14
34
35
  Classifier: Topic :: Communications
35
36
  Classifier: Topic :: Education
36
37
  Classifier: Topic :: Home Automation
@@ -61,8 +62,7 @@ Requires-Dist: build<2; extra == "release"
61
62
  Requires-Dist: twine<7; extra == "release"
62
63
  Provides-Extra: test
63
64
  Requires-Dist: coverage<8; extra == "test"
64
- Requires-Dist: pytest<9; extra == "test"
65
- Requires-Dist: pytest-fixture-order<1; extra == "test"
65
+ Requires-Dist: pytest<10; extra == "test"
66
66
  Requires-Dist: pytest-httpserver<2; extra == "test"
67
67
  Requires-Dist: pytest-ordering<1; extra == "test"
68
68
  Dynamic: license-file
@@ -130,6 +130,10 @@ MQTT server host and port are configurable via pytest cli arguments:
130
130
  You may additionally specify a username and password for connecting to the broker with:
131
131
  ``--mqtt-username`` and ``--mqtt-password``. Default values are ``guest``/``guest``.
132
132
 
133
+ By default, the test fixture subscribes to all topics, listening on ``#``. This can be
134
+ disabled with the ``--no-subscribe-all`` option. You can then subscribe to the topics
135
+ you are interested in within each test using ``capmqtt.mqtt_client.client.subscribe(cpe.info)``.
136
+
133
137
  ``mosquitto`` fixture
134
138
  =====================
135
139
 
@@ -61,6 +61,10 @@ MQTT server host and port are configurable via pytest cli arguments:
61
61
  You may additionally specify a username and password for connecting to the broker with:
62
62
  ``--mqtt-username`` and ``--mqtt-password``. Default values are ``guest``/``guest``.
63
63
 
64
+ By default, the test fixture subscribes to all topics, listening on ``#``. This can be
65
+ disabled with the ``--no-subscribe-all`` option. You can then subscribe to the topics
66
+ you are interested in within each test using ``capmqtt.mqtt_client.client.subscribe(cpe.info)``.
67
+
64
68
  ``mosquitto`` fixture
65
69
  =====================
66
70
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  [project]
8
8
  name = "pytest-mqtt"
9
- version = "0.6.2.dev0"
9
+ version = "0.7.0"
10
10
  description = "pytest-mqtt supports testing systems based on MQTT"
11
11
  readme = "README.rst"
12
12
  keywords = [ "mosquitto", "mqtt", "paho", "pytest", "testing" ]
@@ -39,6 +39,7 @@ classifiers = [
39
39
  "Programming Language :: Python :: 3.11",
40
40
  "Programming Language :: Python :: 3.12",
41
41
  "Programming Language :: Python :: 3.13",
42
+ "Programming Language :: Python :: 3.14",
42
43
  "Topic :: Communications",
43
44
  "Topic :: Education",
44
45
  "Topic :: Home Automation",
@@ -73,8 +74,7 @@ optional-dependencies.release = [
73
74
  ]
74
75
  optional-dependencies.test = [
75
76
  "coverage<8",
76
- "pytest<9",
77
- "pytest-fixture-order<1",
77
+ "pytest<10",
78
78
  "pytest-httpserver<2",
79
79
  "pytest-ordering<1",
80
80
  ]
@@ -100,7 +100,7 @@ line-length = 120
100
100
  [tool.pytest.ini_options]
101
101
  minversion = "2.0"
102
102
  addopts = """
103
- -rfEX -p pytester --strict-markers --verbosity=3
103
+ -rfEXS -p pytester --strict-markers --verbosity=3
104
104
  """
105
105
  log_level = "DEBUG"
106
106
  log_cli_level = "DEBUG"
@@ -35,6 +35,7 @@ class MqttClientAdapter(threading.Thread):
35
35
  port: int = 1883,
36
36
  username: str = "guest",
37
37
  password: str = "guest",
38
+ subscribe_all: bool = True,
38
39
  ):
39
40
  super().__init__()
40
41
  self.client: mqtt.Client
@@ -51,6 +52,7 @@ class MqttClientAdapter(threading.Thread):
51
52
  self.port = int(port)
52
53
  self.username = username
53
54
  self.password = password
55
+ self.subscribe_all = subscribe_all
54
56
 
55
57
  self.setup()
56
58
 
@@ -66,7 +68,8 @@ class MqttClientAdapter(threading.Thread):
66
68
 
67
69
  logger.debug("[PYTEST] Connecting to MQTT broker")
68
70
  client.connect(host=self.host, port=self.port)
69
- client.subscribe("#")
71
+ if self.subscribe_all:
72
+ client.subscribe("#")
70
73
 
71
74
  def run(self) -> None:
72
75
  self.client.loop_start()
@@ -117,13 +120,19 @@ class MqttCaptureFixture:
117
120
  port: int = 1883,
118
121
  username: str = "guest",
119
122
  password: str = "guest",
123
+ subscribe_all: bool = True,
120
124
  ) -> None:
121
125
  """Creates a new funcarg."""
122
126
  self._buffer: t.List[MqttMessage] = []
123
127
  self._decode_utf8: bool = decode_utf8 or False
124
128
 
125
129
  self.mqtt_client = MqttClientAdapter(
126
- on_message_callback=self.on_message, host=host, port=port, username=username, password=password
130
+ on_message_callback=self.on_message,
131
+ host=host,
132
+ port=port,
133
+ username=username,
134
+ password=password,
135
+ subscribe_all=subscribe_all,
127
136
  )
128
137
  self.mqtt_client.start()
129
138
  # time.sleep(0.1)
@@ -178,6 +187,7 @@ def capmqtt(request, mqtt_settings: MqttSettings):
178
187
 
179
188
  host, port = mqtt_settings.host, mqtt_settings.port
180
189
  username, password = mqtt_settings.username, mqtt_settings.password
190
+ subscribe_all = mqtt_settings.subscribe_all
181
191
 
182
192
  capmqtt_decode_utf8 = (
183
193
  getattr(request.config.option, "capmqtt_decode_utf8", False)
@@ -185,7 +195,12 @@ def capmqtt(request, mqtt_settings: MqttSettings):
185
195
  or request.node.get_closest_marker("capmqtt_decode_utf8") is not None
186
196
  )
187
197
  result = MqttCaptureFixture(
188
- decode_utf8=capmqtt_decode_utf8, host=host, port=port, username=username, password=password
198
+ decode_utf8=capmqtt_decode_utf8,
199
+ host=host,
200
+ port=port,
201
+ username=username,
202
+ password=password,
203
+ subscribe_all=subscribe_all,
189
204
  )
190
205
  delay()
191
206
  yield result
@@ -19,3 +19,4 @@ class MqttSettings:
19
19
  port: int
20
20
  username: str
21
21
  password: str
22
+ subscribe_all: bool
@@ -86,6 +86,9 @@ def pytest_addoption(parser) -> None:
86
86
  parser.addoption("--mqtt-port", action="store", type=int, default=1883, help="MQTT port number")
87
87
  parser.addoption("--mqtt-username", action="store", type=str, default="guest", help="Username for connection")
88
88
  parser.addoption("--mqtt-password", action="store", type=str, default="guest", help="Password for connection")
89
+ parser.addoption(
90
+ "--no-subscribe-all", action="store_false", dest="subscribe_all", help="Do not subscribe to all topics"
91
+ )
89
92
 
90
93
 
91
94
  @pytest.fixture(scope="session")
@@ -95,6 +98,7 @@ def mqtt_settings(pytestconfig) -> MqttSettings:
95
98
  port=pytestconfig.getoption("--mqtt-port"),
96
99
  username=pytestconfig.getoption("--mqtt-username"),
97
100
  password=pytestconfig.getoption("--mqtt-password"),
101
+ subscribe_all=pytestconfig.getoption("subscribe_all"),
98
102
  )
99
103
 
100
104
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-mqtt
3
- Version: 0.6.2.dev0
3
+ Version: 0.7.0
4
4
  Summary: pytest-mqtt supports testing systems based on MQTT
5
5
  Author-email: Andreas Motl <andreas.motl@panodata.org>, Richard Pobering <richard.pobering@panodata.org>
6
6
  Project-URL: changelog, https://github.com/mqtt-tools/pytest-mqtt/blob/main/CHANGES.rst
@@ -31,6 +31,7 @@ Classifier: Programming Language :: Python :: 3.10
31
31
  Classifier: Programming Language :: Python :: 3.11
32
32
  Classifier: Programming Language :: Python :: 3.12
33
33
  Classifier: Programming Language :: Python :: 3.13
34
+ Classifier: Programming Language :: Python :: 3.14
34
35
  Classifier: Topic :: Communications
35
36
  Classifier: Topic :: Education
36
37
  Classifier: Topic :: Home Automation
@@ -61,8 +62,7 @@ Requires-Dist: build<2; extra == "release"
61
62
  Requires-Dist: twine<7; extra == "release"
62
63
  Provides-Extra: test
63
64
  Requires-Dist: coverage<8; extra == "test"
64
- Requires-Dist: pytest<9; extra == "test"
65
- Requires-Dist: pytest-fixture-order<1; extra == "test"
65
+ Requires-Dist: pytest<10; extra == "test"
66
66
  Requires-Dist: pytest-httpserver<2; extra == "test"
67
67
  Requires-Dist: pytest-ordering<1; extra == "test"
68
68
  Dynamic: license-file
@@ -130,6 +130,10 @@ MQTT server host and port are configurable via pytest cli arguments:
130
130
  You may additionally specify a username and password for connecting to the broker with:
131
131
  ``--mqtt-username`` and ``--mqtt-password``. Default values are ``guest``/``guest``.
132
132
 
133
+ By default, the test fixture subscribes to all topics, listening on ``#``. This can be
134
+ disabled with the ``--no-subscribe-all`` option. You can then subscribe to the topics
135
+ you are interested in within each test using ``capmqtt.mqtt_client.client.subscribe(cpe.info)``.
136
+
133
137
  ``mosquitto`` fixture
134
138
  =====================
135
139
 
@@ -20,7 +20,6 @@ twine<7
20
20
 
21
21
  [test]
22
22
  coverage<8
23
- pytest<9
24
- pytest-fixture-order<1
23
+ pytest<10
25
24
  pytest-httpserver<2
26
25
  pytest-ordering<1
File without changes
File without changes
File without changes