hi all,
i am having a script file which contains lot of fields and commands.
let's say i have the following word (example1) spread all over the script in every place, how can i replace it with the word (example2)?....the only way i know is to use to either delete the word (example1) and write... (1 Reply)
Hi, can anyone help me? This is what i want to do....I have a string
UNB+UNOA:1+OOCLIES+RTTC+080408:0358+1'
and i want to replace the "1" at the end (that specific field only) to 00001 such that the new output will be like this
UNB+UNOA:1+OOCLIES+RTTC+080408:0358+00001'
i tried using... (5 Replies)
I want to find the top N entries for a certain field based on the values of another field.
For example if N=3, we want the 3 best values for each entry:
Entry1 ||| 100
Entry1 ||| 95
Entry1 ||| 30
Entry1 ||| 80
Entry1 ||| 50
Entry2 ||| 40
Entry2 ||| 20
Entry2 ||| 10
Entry2 ||| 50... (1 Reply)
So, I need to do some summing. I have an Apache log file with the following as a typical line:
127.0.0.1 - frank "GET /apache_pb.gif HTTP/1.0" 200 2326
Now, what I'd like to do is a per-minute sum. So, I can have awk tell me the individual minutes, preserving the dates(since this is a... (7 Replies)
Hi everybody,
I'm trying to replace the $98 field with "T" if the last field (108th) is T
I've tried
awk 'BEGIN{OFS=FS="|"} {if ($108=="T")sub($98,"T"); print}' test.txt
but that doesn't do anything
also tried
awk 'BEGIN{OFS=FS="|"}{ /*T.$/ sub($98,"T")} { print}' test.txt
but... (2 Replies)
Suppose I have a file abc.txt which contain lines:-
11.3.5.7
11.3.6.7
11.6.8.9.10
I want to replace the last field of the line to some value .I want the first line should become 11.3.5.86 .Same applies for rest lines.Please help. (6 Replies)
Hi All,
I have a file yum.conf that has a field called gpgcheck
this field sometimes has a value of 0 gpgcheck=0 and at other times it has a 1.
I need to check the value and if it is a 1 change it to a 0
any ideas?
thanks,
Gartie (1 Reply)
In the tab-delimeted input file below I am trying to use awk to update the value in $2 if TYPE=ins in bold, by adding the value of
HRUN= in italics. In the below since in line 1 TYPE=ins the 117282541 value in $2 has 6 added because that is the value of HRUN=.
Hopefully the awk is a start but I... (2 Replies)
I am trying to output a tab-delimited result that uses the data from a tab-delimited file to combine and subtract specific lines.
If $4 matches in each line then the first matching sequential $6 value is added to $2, unless the value is 1, then the original $2 is used (like in the case of line... (3 Replies)
Hi,
So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies
LEARN ABOUT DEBIAN
py.test-3
PY.TEST-3(1) pytest PY.TEST-3(1)NAME
pytest - pytest usage
CALLING PY.TEST-3 THROUGH PYTHON -M PY.TEST-3
New in version 2.0.
If you use Python-2.5 or later you can invoke testing through the Python interpreter from the command line:
python -m pytest [...]
This is equivalent to invoking the command line script py.test-3 [...] directly.
GETTING HELP ON VERSION, OPTION NAMES, ENVIRONMENT VARIABLES
py.test-3 --version # shows where pytest was imported from
py.test-3 --funcargs # show available builtin function arguments
py.test-3 -h | --help # show help on command line and config file options
STOPPING AFTER THE FIRST (OR N) FAILURES
To stop the testing process after the first (N) failures:
py.test-3 -x # stop after first failure
py.test-3 --maxfail=2 # stop after two failures
SPECIFYING TESTS / SELECTING TESTS
Several test run options:
py.test-3 test_mod.py # run tests in module
py.test-3 somepath # run all tests below path
py.test-3 -k string # only run tests whose names contain a string
Import 'pkg' and use its filesystem location to find and run tests:
py.test-3 --pyargs pkg # run all tests found below directory of pypkg
MODIFYING PYTHON TRACEBACK PRINTING
Examples for modifying traceback printing:
py.test-3 --showlocals # show local variables in tracebacks
py.test-3 -l # show local variables (shortcut)
py.test-3 --tb=long # the default informative traceback formatting
py.test-3 --tb=native # the Python standard library formatting
py.test-3 --tb=short # a shorter traceback format
py.test-3 --tb=line # only one line per failure
DROPPING TO PDB (PYTHON DEBUGGER) ON FAILURES
Python comes with a builtin Python debugger called PDB. py.test-3 allows one to drop into the PDB prompt via a command line option:
py.test-3 --pdb
This will invoke the Python debugger on every failure. Often you might only want to do this for the first failing test to understand a
certain failure situation:
py.test-3 -x --pdb # drop to PDB on first failure, then end test session
py.test-3 --pdb --maxfail=3 # drop to PDB for the first three failures
SETTING A BREAKPOINT / AKA SET_TRACE()
If you want to set a breakpoint and enter the pdb.set_trace() you can use a helper:
import pytest
def test_function():
...
pytest.set_trace() # invoke PDB debugger and tracing
In previous versions you could only enter PDB tracing if you disabled capturing on the command line via py.test-3 -s.
PROFILING TEST EXECUTION DURATION
To get a list of the slowest 10 test durations:
py.test-3 --durations=10
CREATING JUNITXML FORMAT FILES
To create result files which can be read by Hudson or other Continuous integration servers, use this invocation:
py.test-3 --junitxml=path
to create an XML file at path.
CREATING RESULTLOG FORMAT FILES
To create plain-text machine-readable result files you can issue:
py.test-3 --resultlog=path
and look at the content at the path location. Such files are used e.g. by the PyPy-test web page to show test results over several revi-
sions.
SENDING TEST REPORT TO POCOO PASTEBIN SERVICE
Creating a URL for each test failure:
py.test-3 --pastebin=failed
This will submit test run information to a remote Paste service and provide a URL for each failure. You may select tests as usual or add
for example -x if you only want to send one particular failure.
Creating a URL for a whole test session log:
py.test-3 --pastebin=all
Currently only pasting to the http://paste.pocoo.org service is implemented.
CALLING PY.TEST-3 FROM PYTHON CODE
New in version 2.0.
You can invoke py.test-3 from Python code directly:
pytest.main()
this acts as if you would call "py.test-3" from the command line. It will not raise SystemExit but return the exitcode instead. You can
pass in options and arguments:
pytest.main(['x', 'mytestdir'])
or pass in a string:
pytest.main("-x mytestdir")
You can specify additional plugins to pytest.main:
# content of myinvoke.py
import pytest
class MyPlugin:
def pytest_addoption(self, parser):
raise pytest.UsageError("hi from our plugin")
pytest.main(plugins=[MyPlugin()])
Running it will exit quickly:
$ python myinvoke.py
ERROR: hi from our plugin
AUTHOR
holger krekel at merlinux eu
COPYRIGHT
2011, holger krekel et alii
2.2 June 24, 2012 PY.TEST-3(1)