我正在使用主分支和另一个主题分支的git存储库.我已切换到主题分支并修改了一个文件.现在,如果我切换到主分支,则相同的文件显示为已修改.
例如:
git-build分支中的git状态:
# On branch git-build
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: cvsup_current
#
Run Code Online (Sandbox Code Playgroud)
切换到主分支
[root@redbull builder_scripts (git-build)]# git co master
M builder_scripts/cvsup_current
Switched to branch "master"
Run Code Online (Sandbox Code Playgroud)
主分支中的git状态
[root@redbull builder_scripts (master)]# git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: cvsup_current
#
Run Code Online (Sandbox Code Playgroud)
为什么文件在master分支中显示为已修改,即使它在git-build分支中被修改了?
我的理解是,分支是相互独立的,当我从一个分支转换到另一个分支时,变化不会从一个分支"溢出"到另一个分支.所以我显然在这里遗漏了一些东西.
有人拿到了线索吗?
我正在为一系列函数实现单元测试,这些函数都共享多个不变量.例如,调用具有两个矩阵的函数产生已知形状的矩阵.
我想编写单元测试来测试该属性的整个函数系列,而不必为每个函数编写单独的测试用例(特别是因为稍后可能会添加更多函数).
一种方法是迭代这些函数的列表:
import unittest
import numpy
from somewhere import the_functions
from somewhere.else import TheClass
class Test_the_functions(unittest.TestCase):
def setUp(self):
self.matrix1 = numpy.ones((5,10))
self.matrix2 = numpy.identity(5)
def testOutputShape(unittest.TestCase):
"""Output of functions be of a certain shape"""
for function in all_functions:
output = function(self.matrix1, self.matrix2)
fail_message = "%s produces output of the wrong shape" % str(function)
self.assertEqual(self.matrix1.shape, output.shape, fail_message)
if __name__ == "__main__":
unittest.main()
Run Code Online (Sandbox Code Playgroud)
我从Dive Into Python中得到了这个想法.在那里,它不是正在测试的函数列表,而是已知输入 - 输出对的列表.这种方法的问题在于,如果列表中的任何元素未通过测试,则后面的元素不会被测试.
我查看了子类化unittest.TestCase并以某种方式提供了作为参数测试的特定函数,但据我所知,这阻止我们使用unittest.main(),因为没有办法将参数传递给测试用例.
我还看了动态地将"testSomething"函数附加到测试用例,使用带有lamdba的setattr,但是测试用例没有识别它们.
我怎样才能重写这个,所以扩展测试列表仍然是微不足道的,同时仍然确保每个测试都运行?
我有一个使用python smtplib发送邮件的程序。我的邮件发送部分工作正常,但是在发送邮件之后,我还需要捕获服务器返回消息。例如,postfix在邮件排队后返回以下消息:
reply: '250 2.0.0 Ok: queued as EB83821273B\r\n'
reply: retcode (250); Msg: 2.0.0 Ok: queued as EB83821273B
data: (250, '2.0.0 Ok: queued as EB83821273B')
Run Code Online (Sandbox Code Playgroud)
我真正感兴趣的是错误代码(250)和队列ID(EB83821273B)。如果设置set_debuglevel(1),则可以打印这些,但是我需要将其捕获到变量中以进行进一步的日志记录和处理。
谢谢并恭祝安康,
拉吉
有人可以发布一个使用syslog输出器为log4r的例子,我目前正在使用stdout但是想要登录到syslog.
mylog = Logger.new 'mylog'
mylog.outputters = Outputter.stdout
mylog.info "Starting up."
Run Code Online (Sandbox Code Playgroud)
拉吉
还要感谢以下博文.
我正在关注计算机程序的结构和解释,在尝试解决Ex 1.3时,我作为我的第一次尝试得到了以下代码:
(define (sumsq a b c)(
(define highest (if (> (if (> a b) a b) (if (> a c) a c)) (if (> a b) a b) (if (> a c) a c)))
(define second_h (if (> (if (> a b) b a) (if (> a c) c a)) (if (> a b) b a) (if (> a c) c a)))
(+ (* highest highest) (* second_h second_h)))
Run Code Online (Sandbox Code Playgroud)
它没有用,我查找了解决方案并在SICP Wiki上找到了它们
;; ex 1.3
;; …Run Code Online (Sandbox Code Playgroud) 我在Linux中有一个长期运行的ruby脚本,它有一些存储在哈希表中的有趣数据.该程序没有任何持久性机制,我有兴趣从它的哈希表中复制数据.有没有办法从正在运行的ruby脚本的内存中复制数据?
拉吉
我在CouchDB书中遇到了以下代码片段.
function(doc) {
doc.tags && doc.tags.forEach(function(tag) {
emit(tag, 1);
});
}
Run Code Online (Sandbox Code Playgroud)
有人可以解释函数(标签)部分是如何工作的吗?
感谢致敬,
拉吉
python ×2
ruby ×2
couchdb ×1
function ×1
git ×1
git-branch ×1
javascript ×1
log4r ×1
memory ×1
scheme ×1
sicp ×1
smtplib ×1
unit-testing ×1