<commit_before># Onaji

- Author: <NAME>
- Email: <EMAIL>
- Version: 0.0.1

A PyTest plugin for performing regression tests between two commits or two
branches in Git. 

To use Onaji, include it in your `conftest.py` and import the logger object in 
your tests. In each unit test, you call `onaji.log(key, value)` to log an object
to the Onaji backend store. This object will be stored with the commit, branch,
test name, and key. Currently, objects are converted using `repr` but in the
future more formats will be supported.

### Install

```
$ python setup.py install
```

### Usage

##### In your root `conftest.py` make sure to include the plugin:

```python
import pytest

pytest_plugins = ['onaji']
```

##### In each of your pytest files

Include the library

```python
from onaji.logger import onaji
```

Log info in tests

```python
def test_person_name_format_with_nickname():
    assert person.get_nickname_formatted() == ' "Nick"'
    assert person.get_full_name() == "Last, First \"Nick\""
    assert person.format_name("f m l") == "First Middle Last"
    assert person.format_name("p m l") == "Preferred Middle Last"
    assert person.format_name("f n m l") == "First Nick Middle Last"

    onaji.log('person.format_name(f m l)', person.format_name("f m l"))
    onaji.log('person.format_name(p m l)', person.format_name("p m l"))
    onaji.log('person.format_name(p m l)', person.format_name("p m l"))
    onaji.log('person.format_name(f n m l)', person.format_name("f n m l"))
```

Every time you want to run tests against a commit, check out that commit and run 
`pytest`. If your git repo is not at the root of where you run pytest, set the 
`REPO_HOME` environment variable To run the regression diff, use:

```
$ onajidiff <commit_id_a> <commit_id_b>
```

Or to compare two branches:

```
$ onajidiff --branches <branch_name_a> <branch_name_b>
```

<commit_msg>updated readme with example<commit_after># Onaji

- Author: <NAME>
- Email: <EMAIL>
- Version: 0.0.1

A PyTest plugin for performing regression tests between two commits or two
branches in Git. 

To use Onaji, include it in your `conftest.py` and import the logger object in 
your tests. In each unit test, you call `onaji.log(key, value)` to log an object
to the Onaji backend store. This object will be stored with the commit, branch,
test name, and key. Currently, objects are converted using `repr` but in the
future more formats will be supported.

### Install

```
$ python setup.py install
```

### Usage

##### In your root `conftest.py` make sure to include the plugin:

```python
import pytest

pytest_plugins = ['onaji']
```

##### In each of your pytest files

Include the library

```python
from onaji.logger import onaji
```

Log info in tests

```python
def test_person_name_format_with_nickname():
    assert person.get_nickname_formatted() == ' "Nick"'
    assert person.get_full_name() == "Last, First \"Nick\""
    assert person.format_name("f m l") == "First Middle Last"
    assert person.format_name("p m l") == "Preferred Middle Last"
    assert person.format_name("f n m l") == "First Nick Middle Last"

    onaji.log('person.format_name(f m l)', person.format_name("f m l"))
    onaji.log('person.format_name(p m l)', person.format_name("p m l"))
    onaji.log('person.format_name(p m l)', person.format_name("p m l"))
    onaji.log('person.format_name(f n m l)', person.format_name("f n m l"))
```

Every time you want to run tests against a commit, check out that commit and run 
`pytest`. If your git repo is not at the root of where you run pytest, set the 
`REPO_HOME` environment variable To run the regression diff, use:

```
$ onajidiff <commit_id_a> <commit_id_b>
```

Or to compare two branches:

```
$ onajidiff --branches <branch_name_a> <branch_name_b>
```

Example:

```bash
$ onajidiff 9ea881441704a068d650fcd9dd052a606838ad8a 9ea881441704a068d650fcd9dd052a606838ad8b

Reading files.
Reading left file
Reading right file
Done. Comparing.

================================================================================
2 differences. in test_person_name_format_with_nickname :: person.format_name(f n m l)
--------------------------------------------------------------------------------

--- *.9ea881441704a068d650fcd9dd052a606838ad8a

+++ *.9ea881441704a068d650fcd9dd052a606838ad8b

@@ -1 +1 @@

-'First Nick Middle Last'
+'First Nick Middle LastName'
```


{'fraction_non_alphanumeric': 0.15087879479570873, 'fraction_numerical': 0.026706231454005934, 'mean_word_length': 4.060046189376443, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3032271', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1414, 'n_words': 510}