Skip to content

Commit 51fe476

Browse files
committed
go all in on venv for local development
(and clean up the imports in the tests accordingly)
1 parent ff56524 commit 51fe476

28 files changed

+111
-212
lines changed

.coveragerc

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@ omit =
77
*/site-packages/ordereddict.py
88
*/site-packages/nose/*
99
*/unittest2/*
10-
../lib/*
11-
lib/*
1210
tests/*
1311
snipe/_roost_python/*.py

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ parser.out
1010
cover/
1111
.coverage
1212
htmlcov/
13-
lib/
13+
14+
.mypy_cache/
1415

1516
venv/
1617

1718
snipe_im.egg-info/
1819

20+
venv-stamp
21+

Makefile

+33-12
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,46 @@
1-
NOSE=nosetests3
1+
VBIN=venv/bin
2+
FLAKE8=$(VBIN)/flake8
3+
NOSE=$(VBIN)/nosetests
4+
MYPY=$(VBIN)/mypy
5+
COVERAGE=$(VBIN)/coverage
6+
27
NOSETESTS=TZ=GMT $(NOSE) -v -w tests
38

49
all check: flake8 mypy nosetests
510

6-
flake8:
7-
flake8 rooster.py setup.py snipe.py swearing.py snipe tests
11+
flake8: venv
12+
$(FLAKE8) rooster.py setup.py snipe.py swearing.py snipe tests
813

9-
nosetests:
14+
nosetests: venv
1015
$(NOSETESTS) --processes=8 --process-timeout=300
1116

12-
mypy:
13-
mypy --ignore-missing-imports rooster.py setup.py swearing.py snipe tests
17+
mypy: venv
18+
$(MYPY) --ignore-missing-imports rooster.py setup.py swearing.py snipe tests
1419

15-
coverage:
16-
python3-coverage erase
20+
coverage: venv
21+
$(COVERAGE) erase
1722
$(NOSETESTS) --with-coverage
18-
python3-coverage html
23+
$(COVERAGE) html
24+
25+
clean::
26+
$(RM) -r .coverage profiling htmlcov parser.out snipe/parser.out tests/parser.out
27+
28+
venv: venv-stamp
29+
30+
venv-stamp:
31+
$(MAKE) venv-clean
32+
python3 -m venv venv
33+
venv/bin/pip install -U pip
34+
venv/bin/pip install -r ./requirements.txt
35+
venv/bin/pip install mypy flake8 nose coverage
36+
venv/bin/pip install -e .
37+
touch venv-stamp
38+
39+
venv-clean:
40+
$(RM) -rf venv venv-stamp
1941

20-
clean:
21-
$(RM) -r .coverage profiling htmlcov parser.out tests/parser.out
42+
clean:: venv-clean
2243

2344
install:
2445

25-
.PHONY: all clean install check flake8 nosetests
46+
.PHONY: all clean install check flake8 nosetests venv venv-clean

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ client intended for services with persistence. One such service is
1111
[zephyr](https://github.com/zephyr-im). snipe is also has
1212
minimal support for [IRCCloud](https://www.irccloud.com).
1313

14-
I've decided that supporting anything earlier thant python 3.6 isn't
14+
I've decided that supporting anything earlier than python 3.6 isn't
1515
worth it.
1616

1717
M-g in the messager window requires
@@ -27,6 +27,11 @@ It is known that there are bugs and missing features everywhere. I
2727
would mostly characterize this as "demoable" but not yet "usable". As
2828
always, if it breaks you get to keep both pieces.
2929

30+
Running snipe (or the tests) in situ is best done with a virtualenv;
31+
run `make venv` to create one with the appropriate dependencies, or
32+
just `make` to do so and run the tests. Once the venv is set up you
33+
can run `venv/bin/snipe`.
34+
3035
Keybindings
3136
-----------
3237

snipe.py

-44
This file was deleted.

tests/_rooster_tests.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@
3333
'''
3434

3535
import unittest
36-
import sys
3736

38-
sys.path.append('..')
39-
sys.path.append('../lib')
40-
41-
import snipe._rooster as rooster # noqa: E402,F401
37+
import snipe._rooster as rooster # noqa: F401
4238

4339

4440
class TestRooster(unittest.TestCase):

tests/chunks_tests.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@
3333
'''
3434

3535
import unittest
36-
import sys
3736

38-
sys.path.append('..')
39-
sys.path.append('../lib')
40-
41-
from snipe.chunks import Chunk # noqa: E402
37+
from snipe.chunks import Chunk
4238

4339

4440
class TestChunk(unittest.TestCase):

tests/context_tests.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,10 @@
3434

3535
import os
3636
import logging
37-
import sys
3837
import unittest
3938
import tempfile
4039

41-
sys.path.append('..')
42-
sys.path.append('../lib')
43-
44-
import snipe.context as context # noqa: E402,F401
40+
import snipe.context as context
4541

4642

4743
class TestContext(unittest.TestCase):

tests/editor_tests.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,13 @@
3737
import array
3838
import itertools
3939
import random
40-
import sys
4140
import unittest
4241

4342
import mocks
4443

45-
sys.path.append('..')
46-
sys.path.append('../lib')
47-
48-
import snipe.imbroglio # noqa: E402
49-
import snipe.chunks # noqa: E402
50-
import snipe.editor # noqa: E402
44+
import snipe.chunks
45+
import snipe.editor
46+
import snipe.imbroglio
5147

5248

5349
class TestEditor(unittest.TestCase):

tests/filter_tests.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,16 @@
3535
'''
3636

3737
import re
38-
import sys
3938
import unittest
4039

4140
import mocks
4241

43-
sys.path.append('..')
44-
sys.path.append('../lib')
42+
import snipe.filters
4543

46-
import snipe.filters # noqa: E402
4744
from snipe.filters import (
4845
And, Compare, Identifier, Lexer, No, Not, Or, Parser, RECompare,
4946
SnipeFilterError, Truth, Yes, Xor, makefilter,
50-
) # noqa: E402
47+
)
5148

5249

5350
class TestFilters(unittest.TestCase):

tests/help_tests.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,11 @@
3232
Unit tests for help system
3333
'''
3434

35-
import sys
3635
import unittest
3736

38-
sys.path.append('..')
39-
sys.path.append('../lib')
37+
import snipe.help as help
4038

41-
import snipe.help as help # noqa: E402,F401
42-
from snipe.chunks import Chunk, View # noqa: E402,F401
39+
from snipe.chunks import (Chunk, View)
4340

4441

4542
class TestHelp(unittest.TestCase):

tests/interactive_tests.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@
3333
'''
3434

3535
import unittest
36-
import sys
3736

38-
sys.path.append('..')
39-
sys.path.append('../lib')
40-
41-
import snipe.interactive as interactive # noqa: E402,F401
37+
import snipe.interactive as interactive # noqa: F401
4238

4339

4440
class TestInteractive(unittest.TestCase):

tests/irccloud_tests.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,14 @@
3434

3535
import os
3636
import unittest
37-
import sys
3837

3938
import mocks
4039

41-
sys.path.append('..')
42-
sys.path.append('../lib')
40+
import snipe.context as context
41+
import snipe.irccloud as irccloud
42+
import snipe.messages as messages
4343

44-
from snipe.chunks import Chunk # noqa: E402,F401
45-
import snipe.context as context # noqa: E402,F401
46-
import snipe.irccloud as irccloud # noqa: E402,F401
47-
import snipe.messages as messages # noqa: E402,F401
44+
from snipe.chunks import (Chunk)
4845

4946

5047
class TestIRCCloudDecor(unittest.TestCase):

tests/keymap_tests.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@
3535

3636

3737
import curses
38-
import sys
3938
import unittest
4039

41-
sys.path.append('..')
42-
sys.path.append('../lib')
43-
44-
import snipe.keymap # noqa: E402
40+
import snipe.keymap
4541

4642

4743
class TestKeymap(unittest.TestCase):

tests/main_tests.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@
3333
'''
3434

3535
import unittest
36-
import sys
3736

38-
sys.path.append('..')
39-
sys.path.append('../lib')
40-
41-
import snipe.main as main # noqa: E402,F401
37+
import snipe.main as main
4238

4339

4440
class TestMain(unittest.TestCase):

tests/messager_tests.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,16 @@
3737
import io
3838
import math
3939
import os
40-
import sys
4140
import unittest
4241
import unittest.mock as mock
4342

4443
import mocks
4544

46-
sys.path.append('..')
47-
sys.path.append('../lib')
48-
49-
50-
import snipe.chunks as chunks # noqa: E402,F401
51-
import snipe.filters as filters # noqa: E402,F401
52-
import snipe.imbroglio as imbroglio # noqa: E402,F401
53-
import snipe.messager as messager # noqa: E402,F401
54-
import snipe.util as util # noqa: E402,F401
45+
import snipe.chunks as chunks
46+
import snipe.filters as filters
47+
import snipe.imbroglio as imbroglio
48+
import snipe.messager as messager
49+
import snipe.util as util
5550

5651

5752
class TestMessager(unittest.TestCase):

tests/messages_tests.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,16 @@
3636
import datetime
3737
import itertools
3838
import os
39-
import sys
4039
import time
4140
import unittest
4241

4342
import mocks
4443

45-
sys.path.append('..')
46-
sys.path.append('../lib')
47-
48-
import snipe.chunks as chunks # noqa: E402
49-
import snipe.filters as filters # noqa: E402
50-
import snipe.imbroglio as imbroglio # noqa: E402
51-
import snipe.messages as messages # noqa: E402
52-
import snipe.util as util # noqa: E402
44+
import snipe.chunks as chunks
45+
import snipe.filters as filters
46+
import snipe.imbroglio as imbroglio
47+
import snipe.messages as messages
48+
import snipe.util as util
5349

5450

5551
class TestSnipeAddress(unittest.TestCase):

tests/mocks.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,11 @@
4141

4242
from typing import (Dict, Any, List, Optional, Tuple)
4343

44-
sys.path.append('..')
45-
sys.path.append('../lib')
46-
47-
import snipe.chunks # noqa: E402
48-
import snipe.filters # noqa: E402
49-
import snipe.ttycolor # noqa: E402
50-
import snipe.ttyfe # noqa: E402
51-
import snipe.window # noqa: E402
44+
import snipe.chunks
45+
import snipe.filters
46+
import snipe.ttycolor
47+
import snipe.ttyfe
48+
import snipe.window
5249

5350

5451
class Backend:

0 commit comments

Comments
 (0)