在我的办公室计算机上,我已经virtualenv one-for-rule-them-all在Dropbox文件夹中创建了。我想在办公室和家里都使用这种环境。这可能吗?(当前我不成功)
我知道有几个非常相似的主题,但每个主题都有独特的 clang 回溯,我的情况也不例外。
我的 macOS 版本是 Mojave 10.14.2。我安装了命令行工具,$ echo $C_INCLUDE_PATH输出/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include
所以我尝试通过安装 lxml pip install lxml,并获得以下回溯:
Running setup.py bdist_wheel for lxml ... error
Complete output from command /Users/bulrathi/Virtualenvs/gm-test/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/4n/brsfjpqx0kz8lh4rdcz6nb0w0000gn/T/pip-install-8a1v9j7p/lxml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/4n/brsfjpqx0kz8lh4rdcz6nb0w0000gn/T/pip-wheel-wpeizpmd --python-tag cp37:
Building lxml version 3.6.0.
Building without Cython.
Using build configuration of libxslt 1.1.29
Building against libxml2/libxslt in the following directory: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.7
creating build/lib.macosx-10.14-x86_64-3.7/lxml
copying …Run Code Online (Sandbox Code Playgroud) 我对 sqlalchemy(以及 sql)真的很陌生,所以请不要开枪。
我有两个疑问:
user_logins_count = self.request.db.query(
sa.func.count(UserSession.id)
).filter(
sa.and_(
UserSession.user_id == user_id,
sa.between(UserSession.date_login_session, start_date, end_date)
)
)
Run Code Online (Sandbox Code Playgroud)
和
user_questions_count = self.request.db.query(
sa.func.count(QuestionAnswer.id).label('questions_amount')
).filter(
sa.and_(
QuestionAnswer.user_id == user_id,
sa.between(QuestionAnswer.created, start_date, end_date)
)
)
Run Code Online (Sandbox Code Playgroud)
是否可以有一个查询而不是这两个查询?
我有一个非常原始的 Flask 应用程序,它按我的预期工作,但我无法为其编写单元测试。该应用程序的代码如下(我省略了无关紧要的部分):
\n\napp.py\n\nfrom flask import *\nimport random\nimport string\n\napp = Flask(__name__)\nkeys = []\napp.testing = True\n\n@app.route(\'/keygen/api/keys\', methods=[\'POST\'])\ndef create():\n symbol = string.ascii_letters + string.digits\n key = \'\'.join(random.choice(symbol) for _ in range(4))\n key_instance = {\'key\': key, \'is_used\': False}\n keys.append(key_instance)\n\n return jsonify({\'keys\': keys}), 201\nRun Code Online (Sandbox Code Playgroud)\n\n测试是:
\n\ntests.py\n\nimport unittest\nfrom flask import *\nimport app\n\nclass TestCase(unittest.TestCase):\n def test_number_one(self):\n test_app = Flask(app)\n with test_app.test_client() as client:\n rv = client.post(\'/keygen/api/keys\')\n\n ...something...\n\n if __name__ == \'__main__\':\n unittest.main()\nRun Code Online (Sandbox Code Playgroud)\n\n回溯:
\n\nERROR: test_number_one (__main__.TestCase)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File …Run Code Online (Sandbox Code Playgroud) python ×5
dictionary ×1
flask ×1
lxml ×1
macos ×1
pip ×1
python-3.x ×1
sqlalchemy ×1
string ×1
unit-testing ×1
virtualenv ×1