Нет никакого преимущества в выполнении этого. Просто запишите универсальный заголовок сценария, который объясняет вариант использования:
Scenario Outline: Navigating to the home page
Given I navigate to
Then I should see Home page
Examples:
| Application |
| Stack Overflow |
| Math Overflow |
SpecFlow добавит тестовое имя с данными из первого столбца Вашей таблицы в качестве примера:
This is the only thing which worked for me:
C:\> python a.py This" "is" "a" "string^
More?
More? It" "has" "multiple" "lines^
More?
More? There" "are" "three" "total
For me Johannes' solution invokes the python interpreter at the end of the first line, so I don't have the chance to pass additional lines.
But you said you are calling the python script from another process, not from the command line. Then why don't you use dbr' solution? This worked for me as a Ruby script:
puts `python a.py "This is a string\nIt has multiple lines\nThere are three total"`
And in what language are you writing the program which calls the python script? The issue you have is with argument passing, not with the windows shell, not with Python...
Finally, as mattkemp said, I also suggest you use the standard input to read your multi-line argument, avoiding command line magic.
Может работать следующее:
C:\> python something.py "This is a string^
More?
More? It has multiple lines^
More?
More? There are three total"
Просто заключите аргумент в кавычки:
$ python args.py "This is a string
> It has multiple lines
> there are three total"
This is a string
It has multiple lines
there are three total
Вы пытались установить многострочный текст в качестве переменной, а затем передать расширение этого в свой сценарий. Например:
set Text="This is a string
It has multiple lines
there are three total"
python args.py %Text%
В качестве альтернативы, вместо чтения аргумента, который вы могли бы прочитать из стандартного в.
import sys
for line in iter(sys.stdin.readline, ''):
print line
В Linux вы бы передавали многострочный текст на стандартный ввод args.py.
$ <команда-которая-производит -текст> | python args.py
Не уверен насчет командной строки Windows, но будет ли работать следующее?
> python myscript.py "This is a string\nIt has multiple lines\there are three total"
.. или ..
> python myscript.py "This is a string\
It has [...]\
there are [...]"
Если нет, я бы предложил установить Cygwin и использовать нормальную оболочку!
Я знаю, что эта тема довольно старая, но я наткнулся на нее, пытаясь решить похожую проблему, и другие тоже могут, поэтому позвольте мне показать вам, как я ее решил.
Это работает, по крайней мере, на Windows XP Pro, с кодом Зака в файле под названием
"C:\Scratch\test.py":
C:\Scratch>test.py "This is a string"^
More?
More? "It has multiple lines"^
More?
More? "There are three total"
This is a string
It has multiple lines
There are three total
C:\Scratch>
Это немного более читабельно, чем решение Ромуло выше.