File: test_plugin_adder.py

package info (click to toggle)
pastescript 3.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 784 kB
  • sloc: python: 5,212; sh: 65; makefile: 61
file content (25 lines) | stat: -rw-r--r-- 736 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
from paste.script import pluginlib

egg_dir = os.path.join(os.path.dirname(__file__),
                       'fake_packages', 'FakePlugin.egg')

plugin_file = os.path.join(egg_dir, 'paster_plugins.txt')

def plugin_lines():
    if not os.path.exists(plugin_file):
        return []
    f = open(plugin_file)
    lines = f.readlines()
    f.close()
    return [l.strip() for l in lines if l.strip()]

def test_add_remove():
    prev = plugin_lines()
    pluginlib.add_plugin(egg_dir, 'Test')
    assert 'Test' in plugin_lines()
    pluginlib.remove_plugin(egg_dir, 'Test')
    assert 'Test' not in plugin_lines()
    assert prev == plugin_lines()
    if not prev and os.path.exists(plugin_file):
        os.unlink(plugin_file)