Python numpy Log np.testing.assert_equal to a file
I am executing a test I want to capture the error or exception to a log file rather than on console
import logging
import numpy as np
def Log():
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S',
filename='Arming_Command.log',
filemode='w')
def testCase1():
logging.info('Started Test Case 1')
logging.info("Test case 1 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False)
logging.info('Test Case 1 Completed')
def testCase2():
logging.info('Started Test Case 2')
logging.info("Test case 2 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False)
logging.info('Test Case 2 Completed')
if __name__ == '__main__':
Log()
testCase1()
testCase2()
The above code just prints down in console
Traceback (most recent call last): File
"C:/Users/hariom.singh/PycharmProjects/Connect_Pversion/venv/Python_Logging.py",
line 25, in
testCase1() File "C:/Users/hariom.singh/PycharmProjects/Connect_Pversion/venv/Python_Logging.py",
line 14, in testCase1
logging.info("Test case 1 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False) File
"C:Usershariom.singhPycharmProjectsConnect_Pversionvenvlibsite-packagesnumpytesting_privateutils.py",
line 342, in assert_equal
assert_equal(actual[k], desired[k], 'item=%rn%s' % (k, err_msg), verbose) File
"C:Usershariom.singhPycharmProjectsConnect_Pversionvenvlibsite-packagesnumpytesting_privateutils.py",
line 414, in assert_equal
raise AssertionError(msg) AssertionError: Items are not equal: item=1
ACTUAL: 5 DESIRED: 6
Process finished with exit code 1
Console has good information but doesn't log it to my log file
instead I just see in my log file
Thu, 15 Nov 2018 12:53:13 INFO Started Test Case 1
Questions
1)How to capture the information in a log file
2)How to continue executing and logging to log even though there is exception
in my case test Case1 had exception as a result testCase2 didn't run
python numpy
add a comment |
I am executing a test I want to capture the error or exception to a log file rather than on console
import logging
import numpy as np
def Log():
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S',
filename='Arming_Command.log',
filemode='w')
def testCase1():
logging.info('Started Test Case 1')
logging.info("Test case 1 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False)
logging.info('Test Case 1 Completed')
def testCase2():
logging.info('Started Test Case 2')
logging.info("Test case 2 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False)
logging.info('Test Case 2 Completed')
if __name__ == '__main__':
Log()
testCase1()
testCase2()
The above code just prints down in console
Traceback (most recent call last): File
"C:/Users/hariom.singh/PycharmProjects/Connect_Pversion/venv/Python_Logging.py",
line 25, in
testCase1() File "C:/Users/hariom.singh/PycharmProjects/Connect_Pversion/venv/Python_Logging.py",
line 14, in testCase1
logging.info("Test case 1 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False) File
"C:Usershariom.singhPycharmProjectsConnect_Pversionvenvlibsite-packagesnumpytesting_privateutils.py",
line 342, in assert_equal
assert_equal(actual[k], desired[k], 'item=%rn%s' % (k, err_msg), verbose) File
"C:Usershariom.singhPycharmProjectsConnect_Pversionvenvlibsite-packagesnumpytesting_privateutils.py",
line 414, in assert_equal
raise AssertionError(msg) AssertionError: Items are not equal: item=1
ACTUAL: 5 DESIRED: 6
Process finished with exit code 1
Console has good information but doesn't log it to my log file
instead I just see in my log file
Thu, 15 Nov 2018 12:53:13 INFO Started Test Case 1
Questions
1)How to capture the information in a log file
2)How to continue executing and logging to log even though there is exception
in my case test Case1 had exception as a result testCase2 didn't run
python numpy
add a comment |
I am executing a test I want to capture the error or exception to a log file rather than on console
import logging
import numpy as np
def Log():
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S',
filename='Arming_Command.log',
filemode='w')
def testCase1():
logging.info('Started Test Case 1')
logging.info("Test case 1 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False)
logging.info('Test Case 1 Completed')
def testCase2():
logging.info('Started Test Case 2')
logging.info("Test case 2 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False)
logging.info('Test Case 2 Completed')
if __name__ == '__main__':
Log()
testCase1()
testCase2()
The above code just prints down in console
Traceback (most recent call last): File
"C:/Users/hariom.singh/PycharmProjects/Connect_Pversion/venv/Python_Logging.py",
line 25, in
testCase1() File "C:/Users/hariom.singh/PycharmProjects/Connect_Pversion/venv/Python_Logging.py",
line 14, in testCase1
logging.info("Test case 1 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False) File
"C:Usershariom.singhPycharmProjectsConnect_Pversionvenvlibsite-packagesnumpytesting_privateutils.py",
line 342, in assert_equal
assert_equal(actual[k], desired[k], 'item=%rn%s' % (k, err_msg), verbose) File
"C:Usershariom.singhPycharmProjectsConnect_Pversionvenvlibsite-packagesnumpytesting_privateutils.py",
line 414, in assert_equal
raise AssertionError(msg) AssertionError: Items are not equal: item=1
ACTUAL: 5 DESIRED: 6
Process finished with exit code 1
Console has good information but doesn't log it to my log file
instead I just see in my log file
Thu, 15 Nov 2018 12:53:13 INFO Started Test Case 1
Questions
1)How to capture the information in a log file
2)How to continue executing and logging to log even though there is exception
in my case test Case1 had exception as a result testCase2 didn't run
python numpy
I am executing a test I want to capture the error or exception to a log file rather than on console
import logging
import numpy as np
def Log():
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S',
filename='Arming_Command.log',
filemode='w')
def testCase1():
logging.info('Started Test Case 1')
logging.info("Test case 1 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False)
logging.info('Test Case 1 Completed')
def testCase2():
logging.info('Started Test Case 2')
logging.info("Test case 2 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False)
logging.info('Test Case 2 Completed')
if __name__ == '__main__':
Log()
testCase1()
testCase2()
The above code just prints down in console
Traceback (most recent call last): File
"C:/Users/hariom.singh/PycharmProjects/Connect_Pversion/venv/Python_Logging.py",
line 25, in
testCase1() File "C:/Users/hariom.singh/PycharmProjects/Connect_Pversion/venv/Python_Logging.py",
line 14, in testCase1
logging.info("Test case 1 Passed %s",np.testing.assert_equal([4,5], [4,6]),verbose=False) File
"C:Usershariom.singhPycharmProjectsConnect_Pversionvenvlibsite-packagesnumpytesting_privateutils.py",
line 342, in assert_equal
assert_equal(actual[k], desired[k], 'item=%rn%s' % (k, err_msg), verbose) File
"C:Usershariom.singhPycharmProjectsConnect_Pversionvenvlibsite-packagesnumpytesting_privateutils.py",
line 414, in assert_equal
raise AssertionError(msg) AssertionError: Items are not equal: item=1
ACTUAL: 5 DESIRED: 6
Process finished with exit code 1
Console has good information but doesn't log it to my log file
instead I just see in my log file
Thu, 15 Nov 2018 12:53:13 INFO Started Test Case 1
Questions
1)How to capture the information in a log file
2)How to continue executing and logging to log even though there is exception
in my case test Case1 had exception as a result testCase2 didn't run
python numpy
python numpy
edited Nov 15 '18 at 12:57
Hariom Singh
asked Nov 15 '18 at 11:58
Hariom SinghHariom Singh
1,98721228
1,98721228
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53319029%2fpython-numpy-log-np-testing-assert-equal-to-a-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53319029%2fpython-numpy-log-np-testing-assert-equal-to-a-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown