2013-11-21 22 views
5

Burun eklentileriyle ilgili olarak "burun" komutuna özel bir burun eklentisi nasıl eklenir?

Çok fazla araştırma yaptım, ancak burun eklentileriyle ilgili belgeler az görünüyor.

  1. https://nose.readthedocs.org/en/latest/doc_tests/test_init_plugin/init_plugin.html
  2. https://nose.readthedocs.org/en/latest/plugins/writing.html

istemiyorum: okudum ve başarılı olamadı, eklentisi basit bir burun yazıp nosetests ile çalıştırmayı denemek için aşağıdaki linkleri içinde ne denedik kendi test koşumumu yazmak ya da diğer linklerden (run(argv=argv, suite=suite(), ...) aracılığıyla), 'u ilk linkte yaptıkları gibi test etmek için.

import os 
from nose.plugins import Plugin 

class MyCustomPlugin(Plugin): 
    name = 'myplugin' 

    def options(self, parser, env=os.environ): 
     parser.add_option('--custom-path', action='store', 
          dest='custom_path', default=None, 
          help='Specify path to widget config file') 

    def configure(self, options, conf): 
     if options.custom_path: 
      self.make_some_configs(options.custom_path) 
      self.enabled = True 

    def make_some_configs(self, path): 
     # do some stuff based on the given path 

    def begin(self): 
     print 'Maybe print some useful stuff...' 
     # do some more stuff 

ve bunun gibi bir setup.py eklendi:

Böyle bir sınıf ile bir dosyayı myplugin.py yazdı

try: 
    from setuptools import setup, find_packages 
except ImportError: 
    import distribute_setup 
    distribute_setup.use_setuptools() 
    from setuptools import setup, find_packages 

setup(
    name='mypackage', 
    ... 
    install_requires=['nose==1.3.0'], 
    py_modules=['myplugin'], 
    entry_points={ 
     'nose.plugins.1.3.0': [ 
     'myplugin = myplugin:MyCustomPlugin' 
     ] 
    } 
) 

iki dosya aynı dizinde bulunmaktadır.

Ben nosetests --custom-path [path] çalıştırmak her zaman, olsun: Yukarıda belirtilen bağlantılardan

nosetests: error: no such option: --custom-path 

, bunu kayıt ve özel bir eklenti sağlamak için gerekli hepsi bu düşündük. Ama öyle görünüyor ki, ya gerçekten yanlış bir şey yapıyorum ya da burun doktorları modası geçmiş.

Birisi, nosetests ile kullanabileceğim bir eklentiyi kaydettirmek ve etkinleştirmek için lütfen bana doğru yolu işaret edebilir mi?

Çok teşekkürler!

cevap

4

entry_points numaralı nose versiyonunu setup.py içinde istemezsiniz. Dokümanlar söylediğinde sadece nose.plugins.0.10 kullanın. Giriş noktası adındaki noktalı sürüm, bir eklenti API sürümü olarak nose sürümü kadar değil.