guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/04: tests: import: Factorize utility function.


From: Eric Bavier
Subject: 03/04: tests: import: Factorize utility function.
Date: Fri, 09 Jan 2015 16:41:44 +0000

bavier pushed a commit to branch master
in repository guix.

commit 694b317c2dfac5f8b284a5831e20d89cc112bd6b
Author: Eric Bavier <address@hidden>
Date:   Thu Jan 8 14:41:15 2015 -0600

    tests: import: Factorize utility function.
    
    * tests/pypi.scm (mock): Move this...
    * guix/tests.scm: to here.
---
 guix/tests.scm |   11 +++++++++++
 tests/pypi.scm |    9 +--------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/guix/tests.scm b/guix/tests.scm
index 82ae7e2..36341cb 100644
--- a/guix/tests.scm
+++ b/guix/tests.scm
@@ -27,6 +27,7 @@
   #:export (open-connection-for-tests
             random-text
             random-bytevector
+            mock
             with-derivation-narinfo
             dummy-package))
 
@@ -70,6 +71,16 @@
             (loop (1+ i)))
           bv))))
 
+(define-syntax-rule (mock (module proc replacement) body ...)
+  "Within BODY, replace the definition of PROC from MODULE with the definition
+given by REPLACEMENT."
+  (let* ((m (resolve-module 'module))
+         (original (module-ref m 'proc)))
+    (dynamic-wind
+      (lambda () (module-set! m 'proc replacement))
+      (lambda () body ...)
+      (lambda () (module-set! m 'proc original)))))
+
 
 ;;;
 ;;; Narinfo files, as used by the substituter.
diff --git a/tests/pypi.scm b/tests/pypi.scm
index 53c34d9..45cf7ca 100644
--- a/tests/pypi.scm
+++ b/tests/pypi.scm
@@ -20,17 +20,10 @@
   #:use-module (guix import pypi)
   #:use-module (guix base32)
   #:use-module (guix hash)
+  #:use-module (guix tests)
   #:use-module (srfi srfi-64)
   #:use-module (ice-9 match))
 
-(define-syntax-rule (mock (module proc replacement) body ...)
-  (let* ((m (resolve-module 'module))
-         (original (module-ref m 'proc)))
-    (dynamic-wind
-      (lambda () (module-set! m 'proc replacement))
-      (lambda () body ...)
-      (lambda () (module-set! m 'proc original)))))
-
 (define test-json
   "{
   \"info\": {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]