Skip to content

Commit 67b815b

Browse files
committed
Allow running tests with tox without having to re/install the library
1 parent 039a171 commit 67b815b

File tree

3 files changed

+36
-41
lines changed

3 files changed

+36
-41
lines changed

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# python-nostr
2+
23
A Python library for making [Nostr](https://github.com/nostr-protocol/nostr) clients
34

45
## Usage
6+
57
**Generate a key**
8+
69
```python
710
from nostr.key import PrivateKey
811

@@ -11,7 +14,9 @@ public_key = private_key.public_key
1114
print(f"Private key: {private_key.bech32()}")
1215
print(f"Public key: {public_key.bech32()}")
1316
```
17+
1418
**Connect to relays**
19+
1520
```python
1621
import json
1722
import ssl
@@ -27,12 +32,14 @@ time.sleep(1.25) # allow the connections to open
2732
while relay_manager.message_pool.has_notices():
2833
notice_msg = relay_manager.message_pool.get_notice()
2934
print(notice_msg.content)
30-
35+
3136
relay_manager.close_connections()
3237
```
38+
3339
**Publish to relays**
40+
3441
```python
35-
import json
42+
import json
3643
import ssl
3744
import time
3845
from nostr.event import Event
@@ -57,7 +64,9 @@ time.sleep(1) # allow the messages to send
5764

5865
relay_manager.close_connections()
5966
```
67+
6068
**Receive events from relays**
69+
6170
```python
6271
import json
6372
import ssl
@@ -86,21 +95,34 @@ time.sleep(1) # allow the messages to send
8695
while relay_manager.message_pool.has_events():
8796
event_msg = relay_manager.message_pool.get_event()
8897
print(event_msg.event.content)
89-
98+
9099
relay_manager.close_connections()
91100
```
92101

93102
## Installation
103+
94104
```bash
95105
pip install nostr
96106
```
97107

98108
Note: I wrote this with Python 3.9.5.
99109

100-
## Test Suite
101-
See the [Test Suite README](test/README.md)
110+
## Running tests
111+
112+
Install tox
113+
114+
```
115+
pip install tox
116+
```
117+
118+
Run tests
119+
120+
```
121+
tox
122+
```
102123

103124
## Disclaimer
125+
104126
- This library is in very early development.
105127
- It might have some bugs.
106128
- I need to add more tests.

pyproject.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ dynamic=["version"]
2929
[tool.setuptools_scm]
3030
write_to = "nostr/_version.py"
3131

32-
[project.optional-dependencies]
33-
test = [
34-
"pytest >=7.2.0",
35-
"pytest-cov[all]"
36-
]
32+
[tool.tox]
33+
legacy_tox_ini = """
34+
[testenv]
35+
deps =
36+
pytest
37+
pytest-cov[all]
38+
commands =
39+
pytest
40+
"""

test/README.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)