<commit_before>:fire: pyrostest :fire:
=========

The most :fire: lit :fire: ros testing framework.

Pyrostest is a (more) pythonic framework for writing ros tests.

## Why pyrostest?

Writing rostests and rostunit tests is annoying. You have to write launch files
for all of your tests and then do strange things in your unittests and then
somehow the rostests and unittests will communicate. To be honest, I never could
get rostest to work. So I built something better. `pyrostest` allows you to test
your ros nodes in pure python, no need for xml files.

## Usage

Here's a minimal example of a pyrostest test. Assume you have a ros node,
`add_one` in the ros package `pkg`. The node subscribes to `input`, a Float64
message, and published to `output`, another Float64, it adds one to the input
and publishes it. This would test that functionality

```python

from pyrostest import RosTest, launch_node, mock_node, check_topic
from std_msgs.msg import Float64

class TestAddOne(RosTest):
    @launch_node('pkg', 'add_one')
    def test_add_one(self):
        with mock_pub('/input', Flaot64, queue_size=0) as p:
            with check_topic('/output', Float64) as r:
                p.send(Float64(7))
                assert r.message.data == 8  # or self.assertEqual

```

This code will spin up an isolated instance of Roscore, as well as all of the
nodes needed for testing. It will then publish the float 7, and wait until the
data has been recieved, and assert about its value.
<commit_msg>Update readme to use new api.<commit_after>:fire: pyrostest :fire:
=========

The most :fire: lit :fire: ros testing framework.

Pyrostest is a (more) pythonic framework for writing ros tests.

## Why pyrostest?

Writing rostests and rostunit tests is annoying. You have to write launch files
for all of your tests and then do strange things in your unittests and then
somehow the rostests and unittests will communicate. To be honest, I never could
get rostest to work. So I built something better. `pyrostest` allows you to test
your ros nodes in pure python, no need for xml files.

## Usage

Here's a minimal example of a pyrostest test. Assume you have a ros node,
`add_one` in the ros package `pkg`. The node subscribes to `input`, a Float64
message, and published to `output`, another Float64, it adds one to the input
and publishes it. This would test that functionality

```python

from pyrostest import RosTest, launch_node, mock_node
from std_msgs.msg import Float64

class TestAddOne(RosTest):
    @launch_node('pkg', 'add_one')
    def test_add_one(self):
        with self.mock_pub('/input', Flaot64, queue_size=0) as p:
            with self.check_topic('/output', Float64) as r:
                p.send(Float64(7))
                assert r.message.data == 8  # or self.assertEqual

```

This code will spin up an isolated instance of Roscore, as well as all of the
nodes needed for testing. It will then publish the float 7, and wait until the
data has been recieved, and assert about its value.

{'fraction_non_alphanumeric': 0.07444333665669657, 'fraction_numerical': 0.010634762379528082, 'mean_word_length': 3.7929936305732483, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2906489', 'n_tokens_mistral': 909, 'n_tokens_neox': 870, 'n_words': 430}