On Tue, 2018-11-06 at 08:39 +0100, Lukáš Doktor wrote: > Hi Lukáš.
> it looks like you had to make more changes to get this working > without deploying your classes, anyway it should work (and we use it > heavily). Still can't seem to get it to work. > The simplest way to give this a try would be: apricot/test.py: ``` from avocado import Test class ApricotTest(Test): def setUp(self): self.log.info("setUp() executed from Apricot") def some_useful_method(self): return True class MyTest(ApricotTest): """ :avocado: recursive """ def test(self): self.assertTrue(self.some_useful_method()) ``` apricot/__init__.py: ``` __all__ = ['ApricotTest'] from .test import ApricotTest ``` tests/test_example.py: ``` __all__ = ['ApricotTest'] from .test import ApricotTest ``` ./test_example.py: ``` import sys sys.path.append('./') from apricot import ApricotTest class MyTest(ApricotTest): """ :avocado: recursive """ def setUp(self): self.log.info("setUp() executed from test_example.py") def test(self): print "test()" ``` > both work well I'm not sure what "both" are. I assume in your example you were giving a choice of two ways to do something but I couldn't quite work out which were your "or" choices. So with the above, this is what I get: $ avocado run test_example.py JOB ID : 536b1cb21ebd5f10aaf875d9e112a024962efb31 JOB LOG : /home/brian/apricot/avocado/job-results/job-2018-11-06T08.16-536b1cb/job.log (1/1) test_example.py:MyTest.test: PASS (0.03 s) RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 JOB TIME : 0.55 s JOB HTML : /home/brian/apricot/avocado/job-results/job-2018-11-06T08.16-536b1cb/results.html $ cat avocado/job-results/latest/job.log ... 2018-11-06 08:16:05,697 test L0240 INFO | START 1-test_example.py:MyTest.test 2018-11-06 08:16:05,831 test_example L0011 INFO | setUp() executed from test_example.py 2018-11-06 08:16:05,831 output L0655 DEBUG| test() 2018-11-06 08:16:05,832 sysinfo L0366 DEBUG| Not logging /var/log/messages (lack of permissions) 2018-11-06 08:16:05,859 test L0750 INFO | PASS 1-test_example.py:MyTest.test 2018-11-06 08:16:05,860 test L0733 INFO | As you can see, I didn't get the "setUp() executed from Apricot" executing. > I can imagine one possible issue, do you override "__init__" of your > "Test" class? No. > Anyway I'd strongly suggest deploying your library instead of > "sys.path" trickery. I just don't want to dirty up my colleagues personal python libraries. > You can use `--user` to only deploy this for your user. Cleaning > after such deployment is simple even when you lost track of the names > by looking at `rm ~/.local/lib/python$version/site-packages/`. Sure. But I don't really want everyone to have to (know to) do that. I want my testing "tree" to be self-contained. Not to mention that "make install" (which this kind of deploy is) is inherently messy and leads to chaos. > If this did not help, please send more detailed information > (similarly to what I did), ideally with results attached (or at least > the output of `avocado --show all -- test_apricot.py`). That gives me a usage error. I thought it was because I don't have a test_apricot.py, so I tried "avocado --show all -- test_example.py" but that gives the same error: $ avocado --show all -- test_example.py stevedore.extension: found extension EntryPoint.parse('zip_archive = avocado.plugins.archive:ArchiveCLI') stevedore.extension: found extension EntryPoint.parse('tap = avocado.plugins.tap:TAP') stevedore.extension: found extension EntryPoint.parse('journal = avocado.plugins.journal:Journal') stevedore.extension: found extension EntryPoint.parse('json = avocado.plugins.jsonresult:JSONCLI') stevedore.extension: found extension EntryPoint.parse('wrapper = avocado.plugins.wrapper:Wrapper') stevedore.extension: found extension EntryPoint.parse('gdb = avocado.plugins.gdb:GDB') stevedore.extension: found extension EntryPoint.parse('replay = avocado.plugins.replay:Replay') stevedore.extension: found extension EntryPoint.parse('xunit = avocado.plugins.xunit:XUnitCLI') stevedore.extension: found extension EntryPoint.parse('envkeep = avocado.plugins.envkeep:EnvKeep') stevedore.extension: found extension EntryPoint.parse('html = avocado_result_html:HTML') stevedore.extension: found extension EntryPoint.parse('exec-path = avocado.plugins.exec_path:ExecPath') stevedore.extension: found extension EntryPoint.parse('run = avocado.plugins.run:Run') stevedore.extension: found extension EntryPoint.parse('sysinfo = avocado.plugins.sysinfo:SysInfo') stevedore.extension: found extension EntryPoint.parse('list = avocado.plugins.list:List') stevedore.extension: found extension EntryPoint.parse('multiplex = avocado.plugins.multiplex:Multiplex') stevedore.extension: found extension EntryPoint.parse('plugins = avocado.plugins.plugins:Plugins') stevedore.extension: found extension EntryPoint.parse('diff = avocado.plugins.diff:Diff') stevedore.extension: found extension EntryPoint.parse('variants = avocado.plugins.variants:Variants') stevedore.extension: found extension EntryPoint.parse('config = avocado.plugins.config:Config') stevedore.extension: found extension EntryPoint.parse('distro = avocado.plugins.distro:Distro') usage: avocado [-h] [-v] [--config [CONFIG_FILE]] [--show [STREAM[:LVL]]] [-s] {config,diff,distro,exec-path,list,multiplex,plugins,run,sysinfo,variants} ... Avocado Test Runner optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit --config [CONFIG_FILE] Use custom configuration from a file --show [STREAM[:LVL]] List of comma separated builtin logs, or logging streams optionally followed by LEVEL (DEBUG,INFO,...). Builtin streams are: "test": test output; "debug": tracebacks and other debugging info; "app": application output; "early": early logging of other streams, including test (very verbose); "remote": fabric/paramiko debug; "all": all builtin streams; "none": disables regular output (leaving only errors enabled). By default: 'app' -s, --silent disables regular output (leaving only errors enabled) subcommands: valid subcommands {config,diff,distro,exec-path,list,multiplex,plugins,run,sysinfo,variants} subcommand help config Shows avocado config keys diff Shows the difference between 2 jobs. distro Shows detected Linux distribution exec-path Returns path to avocado bash libraries and exits. list List available tests multiplex Tool to analyze and visualize test variants and params plugins Displays plugin information run Runs one or more tests (native test, test alias, binary or script) sysinfo Collect system information variants Tool to analyze and visualize test variants and params avocado: error: argument subcommand: invalid choice: '--' (choose from 'config', 'diff', 'distro', 'exec-path', 'list', 'multiplex', 'plugins', 'run', 'sysinfo', 'variants') Much thanks for you all of your help. Cheers, b.
signature.asc
Description: This is a digitally signed message part