我刚刚开始使用RSpec,我在RSpec github repo上复制了非常简单的测试,以确保事情按预期工作:
require 'spec_helper'
describe 'Home Page' do
it "Welcomes the user" do
visit '/products'
page.should have_content("Welcome")
end
end
Run Code Online (Sandbox Code Playgroud)
当我将字符串更改为"Olá"或"Caçamba"之类的问题时,问题就开始了.任何具有特殊字符的字符串.当我这样做时,我收到以下错误:
invalid multibyte char (US-ASCII) (SyntaxError)
invalid multibyte char (US-ASCII)
syntax error, unexpected $end, expecting ')'
page.should have_content("Olá")
Run Code Online (Sandbox Code Playgroud)
关于如何修复它的任何想法?也许一些配置选项?非常感谢
目前我正在使用:
os.chdir(album.path)
images = glob.glob('*.*')
# thumbs size
size = 80,80
for image in images:
#create thumb
file, ext = os.path.splitext(image)
im = Image.open(os.path.join(album.path,image))
im.thumbnail(size, Image.ANTIALIAS)
thumb_path = os.path.join(album.path, 'thumbs', file + ".thumb" + ".jpeg")
im.save(thumb_path)
Run Code Online (Sandbox Code Playgroud)
虽然这有效,但我最终得到了不同尺寸的图像(有些是肖像,有些是风景),但我希望所有图像都具有精确的尺寸.也许是一个明智的裁剪?
更新:
我不介意裁剪一小部分图像.当我说明智的裁剪时,我的意思是这样的algorythm:
if image is portrait:
make width 80px
crop the height (will be more than 80px)
else if image is landscape:
make height 80px
crop the width to 80px (will be more than 80px)
Run Code Online (Sandbox Code Playgroud) 我即将开始我的第三个中型项目,并希望(我生命中的第一次,我承认)开始使用单元测试.我不知道,使用哪种方法,unitests或doctests.哪种方法最有效,或者初学者应该选择哪种方法?谢谢
django ×2
python ×2
doctest ×1
image ×1
rspec ×1
ruby ×1
testing ×1
thumbnails ×1
unit-testing ×1